Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/DifferenceSubstitutionMatrix.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/DifferenceSubstitutionMatrix.java	(revision 1553)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/DifferenceSubstitutionMatrix.java	(revision 1554)
@@ -29,5 +29,5 @@
 	 * @see de.ugoe.cs.autoquest.plugin.alignment.SubstitutionMatrix#getDistance(int, int)
 	 */
-	public double getDistance(int pos1, int pos2) {
+	public float getDistance(int pos1, int pos2) {
 		return maxValue - (input1[pos1] - input2[pos2]);
 	}
@@ -49,16 +49,11 @@
 
 	@Override
-	public double getGapPenalty() {
+	public float getGapPenalty() {
 		return -maxValue;
-	}
-
-	@Override
-	public String info() {
-		return "Max Value: " + maxValue;
 	}
 
 
 	@Override
-	public void generate(List<IUserSession> sessions) {
+	public void generate() {
 		// TODO Auto-generated method stub
 		
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/NearbySubstitutionMatrix.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/NearbySubstitutionMatrix.java	(revision 1553)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/NearbySubstitutionMatrix.java	(revision 1554)
@@ -29,5 +29,5 @@
 	 * @see de.ugoe.cs.autoquest.plugin.alignment.SubstitutionMatrix#getDistance(int, int)
 	 */
-	public double getDistance(int pos1, int pos2) {
+	public float getDistance(int pos1, int pos2) {
 		int difference = Math.abs(input1[pos1]-input2[pos2]); 
 		if(difference < range) {
@@ -41,15 +41,11 @@
 
 	@Override
-	public double getGapPenalty() {
+	public float getGapPenalty() {
 		return -range-1;
 	}
 
-	@Override
-	public String info() {
-		return "Range: " + range;
-	}
 
 	@Override
-	public void generate(List<IUserSession> sessions) {
+	public void generate() {
 		// TODO Auto-generated method stub
 		
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/ObjectDistanceSubstitionMatrix.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/ObjectDistanceSubstitionMatrix.java	(revision 1553)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/ObjectDistanceSubstitionMatrix.java	(revision 1554)
@@ -3,4 +3,5 @@
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.Iterator;
 
@@ -13,39 +14,26 @@
 import de.ugoe.cs.autoquest.tasktrees.alignment.algorithms.AlignmentHelpers;
 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance;
 import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession;
+import de.ugoe.cs.autoquest.usageprofiles.SymbolMap;
 import de.ugoe.cs.util.console.GlobalDataContainer;
 
 public class ObjectDistanceSubstitionMatrix implements SubstitutionMatrix {
 
-	private ArrayList<int[][]> matrix;
-	private int currentSequence;
-	
-	
-	public ObjectDistanceSubstitionMatrix() {
-		currentSequence = 0;
-		matrix = new ArrayList<int[][]>();
-	}
-	
-	@Override
-	public String info() {
-		// TODO Auto-generated method stub
-		return null;
+	// private ArrayList<int[][]> matrix;
+	HashMap<Integer, Integer> idmapping;
+	private TriangleMatrix matrix;
+	private SymbolMap<ITaskInstance, ITask> uniqueTasks;
+
+	public ObjectDistanceSubstitionMatrix(
+			SymbolMap<ITaskInstance, ITask> uniqueTasks) {
+		this.uniqueTasks = uniqueTasks;
+		idmapping = new HashMap<Integer, Integer>();
+		matrix = new TriangleMatrix(uniqueTasks.size()+1);
 	}
 
 	@Override
-	public double getDistance(int pos1, int pos2) {
-		// TODO Auto-generated method stub
-		
-		return matrix.get(currentSequence)[pos1][pos2];
-	}
-	
-	public double getDistance(int sequence, int pos1, int pos2) {
-		return  matrix.get(sequence)[pos1][pos2];
-		
-		
-	}
-
-	@Override
-	public double getGapPenalty() {
+	public float getGapPenalty() {
 		// TODO Auto-generated method stub
 		return 0;
@@ -53,22 +41,37 @@
 
 	@Override
-	public void generate(List<IUserSession> sessions) {
-		
-		for(Iterator it = sessions.iterator(); it.hasNext();) {
-			IUserSession session = (IUserSession) it.next();
-			matrix.add(new int[sessions.size()][sessions.size()]);
-		
-			
-			for (int i=0; i < session.size(); i++) {
-				for (int j=0; j < session.size(); j++) {
-					//TODO Check if ITaskInstance is of type IEventTaskInstance 
-					IEventTaskInstance eti1 = (IEventTaskInstance) session.get(i);
-					IEventTaskInstance eti2 = (IEventTaskInstance) session.get(j);
-					IGUIElement first = (IGUIElement) eti1.getEvent().getTarget();
-					IGUIElement second =(IGUIElement) eti2.getEvent().getTarget();
-					matrix.get(currentSequence)[i][j] = AlignmentHelpers.distanceBetween(first, second);
+	public void generate() {
+		int i = 0;
+		for (Iterator<ITaskInstance> it = uniqueTasks.getSymbols().iterator(); it
+				.hasNext();) {
+			Object obj1 = it.next();
+			IEventTaskInstance eti1 = null;
+			if (obj1 instanceof IEventTaskInstance) {
+				eti1 = (IEventTaskInstance) obj1;
+			}
+			int j = 0;
+			for (Iterator<ITaskInstance> jt = uniqueTasks.getSymbols()
+					.iterator(); jt.hasNext();) {
+				IEventTaskInstance eti2 = null;
+				Object obj2 = jt.next();
+				if (obj2 instanceof IEventTaskInstance) {
+					eti2 = (IEventTaskInstance) obj2;
 				}
-			}			
+				IGUIElement first = (IGUIElement) eti1.getEvent().getTarget();
+				IGUIElement second = (IGUIElement) eti2.getEvent().getTarget();
+				idmapping.put(eti1.getTask().getId(), i);
+				idmapping.put(eti2.getTask().getId(), j);
+				matrix.set(i, j, AlignmentHelpers.distanceBetween(first, second));
+				j++;
+			}
+			i++;
 		}
 	}
+
+	@Override
+	public float getDistance(int taskId1, int taskId2) {
+		return matrix.get(idmapping.get(taskId1),idmapping.get(taskId2));
+	}
+
 }
+
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/SubstitutionMatrix.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/SubstitutionMatrix.java	(revision 1553)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/SubstitutionMatrix.java	(revision 1554)
@@ -9,12 +9,11 @@
 
 public interface SubstitutionMatrix {
+	
 
-	public String info();
-	
-	public double getDistance(int pos1, int pos2);
+	public float getDistance(int pos1, int pos2);
 
-	public double getGapPenalty();
+	public float getGapPenalty();
 
-	public void generate(List<IUserSession> sessions);
+	public void generate();
 
 	
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/TriangleMatrix.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/TriangleMatrix.java	(revision 1554)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/substitution/TriangleMatrix.java	(revision 1554)
@@ -0,0 +1,43 @@
+package de.ugoe.cs.autoquest.tasktrees.alignment.substitution;
+
+public class TriangleMatrix {
+	
+	private float[] matrix;
+	private int size;
+	
+	public TriangleMatrix(int size) {
+		this.size = size;
+		matrix = new float[size*(size+1)/2];
+	}
+	
+	public float get(int first, int second) {
+		int row = Math.min(first, second);
+		int col = Math.max(first, second);
+		return matrix[row*size-(row*(row+1)/2 - (size-col))];
+		
+	}
+	
+	public void set(int first, int second, float value) {
+		int row = Math.min(first, second);
+		int col = Math.max(first, second);
+		matrix[row*size-(row*(row+1)/2 - (size-col))] = value;
+	}
+
+	
+	//Note: String just looks good for small. testing matrices 
+	public String toString() {
+		String result = "";
+		for (int i = 0; i < size; i++) {
+			for(int j = 0; j< size; j++) {
+				if(i<j) {
+					result = result + (this.get(i,j) + " ");
+				}
+				else {
+					result = result + ("    ");
+				}
+			}
+			result = result + "\n";
+		}
+		return result;
+	}
+}
