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 1619)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/AlignmentAlgorithm.java	(revision 1620)
@@ -6,6 +6,4 @@
 
 public interface AlignmentAlgorithm {
-
-	public abstract void align(int[] input1, int[] input2, SubstitutionMatrix submat,float threshold);
 	
 	/**
@@ -20,5 +18,8 @@
 	public abstract void printAlignment();
 
-	public abstract ArrayList<ArrayList<NumberSequence>> getMatches();
+	public abstract ArrayList<Match> getMatches();
+
+	void align(NumberSequence input1, NumberSequence input2,
+			SubstitutionMatrix submat, float threshold);
 
 }
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/GenerateTask.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/GenerateTask.java	(revision 1620)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/GenerateTask.java	(revision 1620)
@@ -0,0 +1,34 @@
+package de.ugoe.cs.autoquest.tasktrees.alignment.algorithms;
+
+import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory;
+
+public class GenerateTask {
+	
+	
+	private ITaskFactory taskFactory;
+	/**
+	 * <p>
+	 * the task builder to be used for creating substructures for the temporal
+	 * relationships identified during rule application
+	 * </p>
+	 */
+	private ITaskBuilder taskBuilder;
+	
+	void sequence() {
+		ISequence sequence = taskFactory.createNewSequence();
+		//taskBuilder.addChild(sequence,ITask);
+		
+	}
+	
+	
+	void iteration() {
+		IIteration iteration = taskFactory.createNewIteration();
+		//taskBuilder.setMarkedTask(iteration, child);
+	}
+	
+	
+	
+}
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/Match.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/Match.java	(revision 1620)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/Match.java	(revision 1620)
@@ -0,0 +1,43 @@
+package de.ugoe.cs.autoquest.tasktrees.alignment.algorithms;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+
+public class Match {
+	private ArrayList<NumberSequence> matchseqs;
+	
+	private LinkedList<MatchOccurence> occurences; 
+	
+	
+	Match(){
+		matchseqs = new ArrayList<NumberSequence>(2);
+		occurences = new LinkedList<MatchOccurence>();
+		matchseqs.add(null);
+		matchseqs.add(null);
+	}
+	
+	public NumberSequence getFirstSequence() {
+		return matchseqs.get(0);
+	}
+	
+	public NumberSequence getSecondSequence() {
+		return matchseqs.get(1);
+	}
+	
+	public void setFirstSequence(NumberSequence seq) {
+		matchseqs.set(0, seq);
+	}
+	
+	public void setSecondSequence(NumberSequence seq) {
+		matchseqs.set(1, seq);
+	}
+	
+	public void addOccurence(MatchOccurence occurence) {
+		occurences.add(occurence);
+	}
+	
+	public int occurenceCount() {
+		return occurences.size();
+	}	
+
+}
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/MatchOccurence.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/MatchOccurence.java	(revision 1620)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/MatchOccurence.java	(revision 1620)
@@ -0,0 +1,19 @@
+package de.ugoe.cs.autoquest.tasktrees.alignment.algorithms;
+
+public class MatchOccurence {
+	private int startindex;
+	private int sequenceId;
+	public MatchOccurence(int startindex, int sequenceId) {
+		this.startindex = startindex;
+		this.sequenceId = sequenceId;
+	}
+	public int getStartindex() {
+		return startindex;
+	}
+	public void setStartindex(int startindex) {
+		this.startindex = startindex;
+	}
+	public int getSequenceId() {
+		return sequenceId;
+	}
+}
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 1619)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/NeedlemanWunsch.java	(revision 1620)
@@ -260,5 +260,5 @@
 
 	@Override
-	public ArrayList<ArrayList<NumberSequence>> getMatches() {
+	public ArrayList<Match> getMatches() {
 		// TODO Auto-generated method stub
 		return null;
@@ -266,10 +266,10 @@
 
 	@Override
-	public void align(int[] input1, int[] input2, SubstitutionMatrix submat,
+	public void align(NumberSequence input1, NumberSequence input2, SubstitutionMatrix submat,
 			float threshold) {
-		this.input1 = input1;
-		this.input2 = input2;
-		length1 = input1.length;
-		length2 = input2.length;
+		this.input1 = input1.getSequence();
+		this.input2 = input2.getSequence();
+		length1 = input1.size();
+		length2 = input2.size();
 		this.submat = submat;
 
Index: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/NumberSequence.java
===================================================================
--- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/NumberSequence.java	(revision 1619)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/NumberSequence.java	(revision 1620)
@@ -6,5 +6,20 @@
 public class NumberSequence {
 	private int[] sequence;
-	private int signature;
+	private int id;
+
+	public ArrayList<Match> getMatches() {
+		return matches;
+	}
+
+
+	public void setMatches(ArrayList<Match> matches) {
+		this.matches = matches;
+	}
+	
+	public void addMatches(ArrayList<Match> matches) {
+		this.matches.addAll(matches);
+	}
+
+	private ArrayList<Match> matches;
 
 	public NumberSequence(int size) {
@@ -12,5 +27,5 @@
 		sequence = new int[size];
 	}
-
+	
 	public int[] getSequence() {
 		return sequence;
@@ -21,11 +36,5 @@
 	}
 
-	public int getSignature() {
-		return signature;
-	}
-
-	public void setSignature(int signature) {
-		this.signature = signature;
-	}
+	
 
 	public void printSequence() {
@@ -38,4 +47,5 @@
 	public NumberSequence shuffle() {
 		NumberSequence result = new NumberSequence(sequence.length);
+		result.setId(getId());
 		result.setSequence(this.sequence);
 		Random rgen = new Random();
@@ -51,18 +61,30 @@
 	}
 
-	// TODO: This can be done faster
-	public int containsPattern(ArrayList<NumberSequence> pattern) {
+
+	public int containsPattern(Match pattern) {
 		int i = 0;
 		int count = 0;
-		int[] pat1 = pattern.get(0).getSequence();
-		int[] pat2 = pattern.get(1).getSequence();
+		int[] pat1 = pattern.getFirstSequence().getSequence();
+		int[] pat2 = pattern.getSecondSequence().getSequence();
 		notmatched: while (i < sequence.length - pat1.length) {
 			if (sequence[i] == pat1[0] || sequence[i] == pat2[0]) {
-				for (int j = 0; j < pat1.length; j++) {
-					if (sequence[i + j] != pat1[j]
-							&& sequence[i + j] != pat2[j]) {
+				int ipat1 =0;
+				int ipat2 =0;
+				while(ipat1 < pat1.length && ipat2<pat2.length) {
+					if(pat1[ipat1]==-1) {
+						ipat1++;
+						continue;
+					}
+					if(pat2[ipat2]==-1) {
+						ipat2++;
+						continue;
+					}
+					if (sequence[i + ipat1] != pat1[ipat1]
+							&& sequence[i + ipat2] != pat2[ipat2]) {
 						i++;
 						continue notmatched;
 					}
+					ipat1++;
+					ipat2++;
 				}
 				count++;
@@ -72,7 +94,28 @@
 		return count;
 	}
+	
+	//Returns the number of times event occurs in this sequence
+	public int eventCount(int event) {
+		int count = 0;
+		for(int i=0;i<sequence.length;i++) {
+			if(sequence[i] == event) {
+				count++;
+			}
+		}
+		return count;
+	}
 
 	public int size() {
 		return sequence.length;
 	}
+
+
+	public int getId() {
+		return id;
+	}
+
+
+	public void setId(int id) {
+		this.id = id;
+	}
 }
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 1619)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWaterman.java	(revision 1620)
@@ -265,5 +265,5 @@
 
 	@Override
-	public ArrayList<ArrayList<NumberSequence>> getMatches() {
+	public ArrayList<Match> getMatches() {
 		// TODO Auto-generated method stub
 		return null;
@@ -271,10 +271,10 @@
 
 	@Override
-	public void align(int[] input1, int[] input2, SubstitutionMatrix submat,
+	public void align(NumberSequence input1, NumberSequence input2, SubstitutionMatrix submat,
 			float threshold) {
-		this.input1 = input1;
-		this.input2 = input2;
-		length1 = input1.length;
-		length2 = input2.length;
+		this.input1 = input1.getSequence();
+		this.input2 = input2.getSequence();
+		length1 = input1.size();
+		length2 = input2.size();
 		this.submat = submat;
 
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 1619)
+++ branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWatermanRepeated.java	(revision 1620)
@@ -231,7 +231,9 @@
 		ns1.setSequence(reversed1);
 		ns2.setSequence(reversed2);
-
-		alignment.add(ns1);
-		alignment.add(ns2);
+		ns1.setId(alignment.get(0).getId());
+		ns2.setId(alignment.get(1).getId());
+		
+		alignment.set(0, ns1);
+		alignment.set(1, ns2);
 	}
 	
@@ -272,6 +274,6 @@
 	}
 	
-	public ArrayList<ArrayList<NumberSequence>> getMatches() {
-		ArrayList<ArrayList<NumberSequence>> result = new ArrayList<ArrayList<NumberSequence>>();
+	public ArrayList<Match> getMatches() {
+		ArrayList<Match> result = new ArrayList<Match>();
 		
 		//both alignment sequences should be equally long
@@ -288,5 +290,5 @@
 					count++;
 				}
-				//I am really missing memcpy here 
+				//I am really missing memcpy here? How does one do this better in java? 
 				int[] tmp1 = new int[count];
 				int[] tmp2 = new int[count];
@@ -299,19 +301,14 @@
 				tmpns1.setSequence(tmp1);
 				tmpns2.setSequence(tmp2);
-				ArrayList<NumberSequence> tmpal = new ArrayList<NumberSequence>();
-				tmpal.add(tmpns1);
-				tmpal.add(tmpns2);
+				Match tmpal = new Match();
+				tmpal.setFirstSequence(tmpns1);
+				tmpal.setSecondSequence(tmpns2);
+				tmpal.addOccurence(new MatchOccurence(start,alignment.get(0).getId()));
+				tmpal.addOccurence(new MatchOccurence(start,alignment.get(1).getId()));
 				result.add(tmpal);
 			}
 			i++;
 		}
-		
-		
-		
-		
-		
-		
 		return result;
-		
 	}
 	
@@ -354,10 +351,16 @@
 
 	@Override
-	public void align(int[] input1, int[] input2, SubstitutionMatrix submat,
+	public void align(NumberSequence input1, NumberSequence input2, SubstitutionMatrix submat,
 			float threshold) {
-		this.input1 = input1;
-		this.input2 = input2;
-		length1 = input1.length;
-		length2 = input2.length;
+		
+		alignment = new ArrayList<NumberSequence>();
+		alignment.add(input1);
+		alignment.add(input2);
+		
+		this.input1=input1.getSequence();
+		this.input2=input2.getSequence();
+		
+		length1 = input1.size();
+		length2 = input2.size();
 		this.submat = submat;
 
@@ -367,5 +370,5 @@
 		
 		matrix = new MatrixEntry[length1+2][length2+1];
-		alignment = new ArrayList<NumberSequence>();
+		
 		
 		for (int i = 0; i <= length1+1; i++) {
