Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/AlignmentAlgorithm.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/AlignmentAlgorithm.java	(revision 1596)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/AlignmentAlgorithm.java	(revision 1612)
@@ -3,6 +3,10 @@
 import java.util.ArrayList;
 
+import de.ugoe.cs.autoquest.tasktrees.alignment.matrix.SubstitutionMatrix;
+
 public interface AlignmentAlgorithm {
 
+	public abstract void align(int[] input1, int[] input2, SubstitutionMatrix submat,float threshold);
+	
 	/**
 	 * Get the alignment score between the two input strings.
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/AlignmentAlgorithmFactory.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/AlignmentAlgorithmFactory.java	(revision 1596)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/AlignmentAlgorithmFactory.java	(revision 1612)
@@ -1,3 +1,6 @@
 package de.ugoe.cs.autoquest.tasktrees.alignment.algorithms;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 
 import de.ugoe.cs.autoquest.tasktrees.alignment.matrix.SubstitutionMatrix;
@@ -5,10 +8,28 @@
 public class AlignmentAlgorithmFactory {
 	
+	public static void setDefaultAlgorithm(String algorithmname) {
+		//TODO: check for valid algorihm class names here
+		algorithmclass = algorithmname;
+	}
 	
-	public static AlignmentAlgorithm create(int[] input1, int[] input2, SubstitutionMatrix submat,float threshold) {
-		
+	private static String algorithmclass = "de.ugoe.cs.autoquest.tasktrees.alignment.algorithms.SmithWatermanRepeated";
+	
+	
+	
+	public static AlignmentAlgorithm create() {
+		Class<?> newclass;
+		Object object = null;
+		try {
+			 newclass = Class.forName(algorithmclass);
+			 object = newclass.newInstance();
+			
+		} catch (ClassNotFoundException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
 		//return new SmithWaterman(input1,input2,submat,threshold);
 		//return new NeedlemanWunsch(input1,input2,submat,threshold);
-		return new SmithWatermanRepeated(input1,input2,submat,threshold);
+		//return new SmithWatermanRepeated(input1,input2,submat,threshold);
+		return (AlignmentAlgorithm) object;
 	}
 }
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/NeedlemanWunsch.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/NeedlemanWunsch.java	(revision 1596)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/NeedlemanWunsch.java	(revision 1612)
@@ -39,28 +39,4 @@
 	private SubstitutionMatrix submat;
 
-	public NeedlemanWunsch(int[] input1, int[] input2, SubstitutionMatrix submat,
-			float threshold) {
-		this.input1 = input1;
-		this.input2 = input2;
-		length1 = input1.length;
-		length2 = input2.length;
-		this.submat = submat;
-
-		// System.out.println("Starting SmithWaterman algorithm with a "
-		// + submat.getClass() + " Substitution Matrix: " +
-		// submat.getClass().getCanonicalName());
-
-		matrix = new MatrixEntry[length1 + 1][length2 + 1];
-		alignment = new ArrayList<NumberSequence>();
-
-		for (int i = 0; i < length1+1; i++) {
-			for (int j = 0; j < length2+1; j++) {
-				matrix[i][j] = new MatrixEntry();
-			}
-		}
-
-		buildMatrix();
-		traceback();
-	}
 
 	/**
@@ -289,4 +265,31 @@
 	}
 
+	@Override
+	public void align(int[] input1, int[] input2, SubstitutionMatrix submat,
+			float threshold) {
+		this.input1 = input1;
+		this.input2 = input2;
+		length1 = input1.length;
+		length2 = input2.length;
+		this.submat = submat;
+
+		// System.out.println("Starting SmithWaterman algorithm with a "
+		// + submat.getClass() + " Substitution Matrix: " +
+		// submat.getClass().getCanonicalName());
+
+		matrix = new MatrixEntry[length1 + 1][length2 + 1];
+		alignment = new ArrayList<NumberSequence>();
+
+		for (int i = 0; i < length1+1; i++) {
+			for (int j = 0; j < length2+1; j++) {
+				matrix[i][j] = new MatrixEntry();
+			}
+		}
+
+		buildMatrix();
+		traceback();
+		
+	}
+
 
 
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWaterman.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWaterman.java	(revision 1596)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWaterman.java	(revision 1612)
@@ -38,28 +38,4 @@
 	private SubstitutionMatrix submat;
 
-	public SmithWaterman(int[] input1, int[] input2, SubstitutionMatrix submat,
-			float threshold) {
-		this.input1 = input1;
-		this.input2 = input2;
-		length1 = input1.length;
-		length2 = input2.length;
-		this.submat = submat;
-
-		// System.out.println("Starting SmithWaterman algorithm with a "
-		// + submat.getClass() + " Substitution Matrix: " +
-		// submat.getClass().getCanonicalName());
-
-		matrix = new MatrixEntry[length1 + 1][length2 + 1];
-		alignment = new ArrayList<NumberSequence>();
-
-		for (int i = 0; i < length1+1; i++) {
-			for (int j = 0; j < length2+1; j++) {
-				matrix[i][j] = new MatrixEntry();
-			}
-		}
-
-		buildMatrix();
-		traceback();
-	}
 
 	/**
@@ -294,3 +270,30 @@
 	}
 
+	@Override
+	public void align(int[] input1, int[] input2, SubstitutionMatrix submat,
+			float threshold) {
+		this.input1 = input1;
+		this.input2 = input2;
+		length1 = input1.length;
+		length2 = input2.length;
+		this.submat = submat;
+
+		// System.out.println("Starting SmithWaterman algorithm with a "
+		// + submat.getClass() + " Substitution Matrix: " +
+		// submat.getClass().getCanonicalName());
+
+		matrix = new MatrixEntry[length1 + 1][length2 + 1];
+		alignment = new ArrayList<NumberSequence>();
+
+		for (int i = 0; i < length1+1; i++) {
+			for (int j = 0; j < length2+1; j++) {
+				matrix[i][j] = new MatrixEntry();
+			}
+		}
+
+		buildMatrix();
+		traceback();
+		
+	}
+
 }
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWatermanRepeated.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWatermanRepeated.java	(revision 1596)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWatermanRepeated.java	(revision 1612)
@@ -43,27 +43,6 @@
 	private SubstitutionMatrix submat;
 
-	public SmithWatermanRepeated(int[] input1, int[] input2, SubstitutionMatrix submat,float threshold) {
-		this.input1 = input1;
-		this.input2 = input2;
-		length1 = input1.length;
-		length2 = input2.length;
-		this.submat = submat;
-
-		//System.out.println("Starting SmithWaterman algorithm with a "
-		//		+ submat.getClass() + " Substitution Matrix: " + submat.getClass().getCanonicalName());
-		this.scoreThreshold = threshold;
-		
-		matrix = new MatrixEntry[length1+2][length2+1];
-		alignment = new ArrayList<NumberSequence>();
-		
-		for (int i = 0; i <= length1+1; i++) {
-			for(int j = 0; j< length2; j++) {
-				matrix[i][j] = new MatrixEntry();
-			}
-		}
-	
-
-		buildMatrix();
-		traceback();
+	public SmithWatermanRepeated() {
+	
 	}
 
@@ -374,3 +353,30 @@
 	}
 
+	@Override
+	public void align(int[] input1, int[] input2, SubstitutionMatrix submat,
+			float threshold) {
+		this.input1 = input1;
+		this.input2 = input2;
+		length1 = input1.length;
+		length2 = input2.length;
+		this.submat = submat;
+
+		//System.out.println("Starting SmithWaterman algorithm with a "
+		//		+ submat.getClass() + " Substitution Matrix: " + submat.getClass().getCanonicalName());
+		this.scoreThreshold = threshold;
+		
+		matrix = new MatrixEntry[length1+2][length2+1];
+		alignment = new ArrayList<NumberSequence>();
+		
+		for (int i = 0; i <= length1+1; i++) {
+			for(int j = 0; j< length2; j++) {
+				matrix[i][j] = new MatrixEntry();
+			}
+		}
+	
+
+		buildMatrix();
+		traceback();
+	}
+
 }
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/matrix/PairwiseAlignmentGenerator.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/matrix/PairwiseAlignmentGenerator.java	(revision 1596)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/matrix/PairwiseAlignmentGenerator.java	(revision 1612)
@@ -21,20 +21,23 @@
     				if (i != j) {
     					int smithWatermanThreshold = 10;
-
-    					alignments.set(i, j,AlignmentAlgorithmFactory.create(
-    							ns1.getSequence(), ns2.getSequence(), submat,
-    							smithWatermanThreshold));
+    					AlignmentAlgorithm aa = AlignmentAlgorithmFactory.create();
+    					aa.align(ns1.getSequence(), ns2.getSequence(), submat,
+    							smithWatermanThreshold);
+    					alignments.set(i,j,aa);
+    				
     					
-    					AlignmentAlgorithm sameSequence1 = AlignmentAlgorithmFactory.create(
+    					AlignmentAlgorithm sameSequence1 = AlignmentAlgorithmFactory.create();
+    							sameSequence1.align(
     							ns1.getSequence(), ns1.getSequence(), submat,
     							smithWatermanThreshold);
-    					AlignmentAlgorithm sameSequence2 = AlignmentAlgorithmFactory.create(
-    							ns2.getSequence(), ns2.getSequence(), submat,
+    					AlignmentAlgorithm sameSequence2 = AlignmentAlgorithmFactory.create();
+    							sameSequence2.align(ns2.getSequence(), ns2.getSequence(), submat,
     							smithWatermanThreshold);
-    					AlignmentAlgorithm randomSequence = AlignmentAlgorithmFactory.create(
-    							ns1.shuffle().getSequence(),ns2.shuffle().getSequence(),submat,smithWatermanThreshold);
+    					AlignmentAlgorithm randomSequence = AlignmentAlgorithmFactory.create();
+    							randomSequence.align(ns1.shuffle().getSequence(),ns2.shuffle().getSequence(),submat,smithWatermanThreshold);
     					
     					// Score of the aligmnment
     					double score = alignments.get(i,j).getAlignmentScore();
+    					/*
     					if(score > 0) {
     						System.out.println("Alignment: " + i + " " + j);
@@ -52,4 +55,5 @@
     						System.out.println();
     					}
+    					*/
     					// Scores of the sequence being aligned to itself (maximum score)
     					double sSelf1 = sameSequence1.getAlignmentScore();
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/pal/tree/UPGMAAligningTree.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/pal/tree/UPGMAAligningTree.java	(revision 1596)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/pal/tree/UPGMAAligningTree.java	(revision 1612)
@@ -18,4 +18,5 @@
 import java.util.logging.Level;
 
+import de.ugoe.cs.autoquest.tasktrees.alignment.algorithms.AlignmentAlgorithm;
 import de.ugoe.cs.autoquest.tasktrees.alignment.algorithms.AlignmentAlgorithmFactory;
 import de.ugoe.cs.autoquest.tasktrees.alignment.algorithms.NumberSequence;
@@ -221,5 +222,7 @@
 			//Align 2 sequences
 			if(seqCount1 == 1 && seqCount2 == 1) {
-				alignment = (alignments.get(node1.getNumber(), node2.getNumber())).getAlignment();
+				AlignmentAlgorithm aa = AlignmentAlgorithmFactory.create();
+				aa.align(node1.getSequence(0).getSequence(), node2.getSequence(0).getSequence(), submat, 5);
+				alignment = aa.getAlignment();
 				
 			}
@@ -231,6 +234,9 @@
 				double maxScore = 0.0;
 				int maxIndex = 0;
-				for(int i=0;i<seqCount1;i++) {
-					tempStorage.set(i, 1, AlignmentAlgorithmFactory.create(node1.getSequence(i).getSequence(), node2.getSequence(0).getSequence() , submat, 5));
+				for(int i=0;i<seqCount1;i++){
+					AlignmentAlgorithm aa = AlignmentAlgorithmFactory.create();
+					aa.align(node1.getSequence(i).getSequence(), node2.getSequence(0).getSequence() , submat, 5);
+					tempStorage.set(i, 1, aa);
+					
 					if(maxScore < tempStorage.get(i, 1).getAlignmentScore()) {
 						maxScore = tempStorage.get(i, 1).getAlignmentScore();
@@ -249,5 +255,7 @@
 				int maxIndex = 0;
 				for(int i=0;i<seqCount2;i++) {
-					tempStorage.set(1, i, AlignmentAlgorithmFactory.create(node2.getSequence(i).getSequence(), node1.getSequence(0).getSequence() , submat, 5));
+					AlignmentAlgorithm aa = AlignmentAlgorithmFactory.create();
+					aa.align(node2.getSequence(i).getSequence(), node1.getSequence(0).getSequence() , submat, 5);
+					tempStorage.set(1, i, aa);
 					if(maxScore < tempStorage.get(1, i).getAlignmentScore()) {
 						maxScore = tempStorage.get(1, i).getAlignmentScore();
@@ -269,5 +277,7 @@
 					for(int i=0;i<seqCount1;i++) {
 						for(int j=0;j<seqCount2;j++) {
-							tempStorage1.set(j, 0, AlignmentAlgorithmFactory.create(node1.getSequence(i).getSequence(), node2.getSequence(j).getSequence() , submat, 5));
+							AlignmentAlgorithm aa =AlignmentAlgorithmFactory.create();
+							aa.align(node1.getSequence(i).getSequence(), node2.getSequence(j).getSequence() , submat, 5);
+							tempStorage1.set(j, 0, aa);
 							if(maxScore1 < tempStorage1.get(j, 0).getAlignmentScore()) {
 								maxScore1 = tempStorage1.get(j, 0).getAlignmentScore();
@@ -280,5 +290,7 @@
 					for(int i=0; i<seqCount2;i++) {
 						for (int j=0;j<seqCount1;j++) {
-							tempStorage2.set(j, 0, AlignmentAlgorithmFactory.create(node2.getSequence(i).getSequence(),node1.getSequence(j).getSequence(),submat,5));
+							AlignmentAlgorithm aa =AlignmentAlgorithmFactory.create();
+							aa.align(node2.getSequence(i).getSequence(),node1.getSequence(j).getSequence(),submat,5);
+							tempStorage2.set(j, 0, aa);
 							if(maxScore2 < tempStorage2.get(j, 0).getAlignmentScore()) {
 								maxScore2 = tempStorage2.get(j, 0).getAlignmentScore();
