Index: /trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRule.java
===================================================================
--- /trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRule.java	(revision 1887)
+++ /trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRule.java	(revision 1888)
@@ -479,5 +479,5 @@
                     // Trie must be recreated with a longer sequence length to be sure that
                     // the found sequences occurring most often are found in their whole length
-                    appData.setTrainedSubsequenceLength(appData.getTrainedSubsequenceLength() + 1);
+                    appData.setTrainedSubsequenceLength(appData.getTrainedSubsequenceLength() + 3);
                     createNewTrie = true;
                     break;
@@ -835,7 +835,7 @@
                 // checking now, if there is one sequence, having the lowest index for any of
                 // its collisions and preserve it. If there are several ones with the same minimum
-                // index, throw an exception
+                // index, check if they are indpendent. If not, throw an exception
                 int minPosInAnySequence = Integer.MAX_VALUE;
-                InterleavingSubsequence subsequenceWithMinPos = null;
+                List<InterleavingSubsequence> subsequencesWithMinPos = new LinkedList<>();
                 
                 for (InterleavingSubsequence interleaving : interleavings) {
@@ -843,27 +843,39 @@
                         if (minPosInAnySequence > collision.getLocation().getIndex()) {
                             minPosInAnySequence = collision.getLocation().getIndex();
-                            subsequenceWithMinPos = interleaving;
+                            subsequencesWithMinPos.clear();
                         }
-                        else if (minPosInAnySequence == collision.getLocation().getIndex()) {
+                        
+                        if (minPosInAnySequence == collision.getLocation().getIndex()) {
                             // several have the same min pos --> undecidable which to prefer
-                            subsequenceWithMinPos = null;
+                            subsequencesWithMinPos.add(interleaving);
                         }
                     }
                 }
                 
-                if (subsequenceWithMinPos != null) {
+                if (subsequencesWithMinPos.size() > 0) {
                     List<Subsequence> subsequencesToRemove = new LinkedList<Subsequence>();
                     
                     for (Subsequence candidate : appData.getLastFoundSubsequences()) {
-                        if (candidate != subsequenceWithMinPos.getSubsequence()) {
+                        boolean found = false;
+                        
+                        for (InterleavingSubsequence subsequenceWithMinPos : subsequencesWithMinPos)
+                        {
+                            if (candidate == subsequenceWithMinPos.getSubsequence()) {
+                                found = true;
+                            }
+                        }
+                        
+                        if (!found) {
                             subsequencesToRemove.add(candidate);
                         }
                     }
                     
-                    for (Subsequence candidate : subsequencesToRemove) {
-                        appData.getLastFoundSubsequences().remove(candidate);
-                    }
+                    if (subsequencesToRemove.size() > 0) {
+                        for (Subsequence candidate : subsequencesToRemove) {
+                            appData.getLastFoundSubsequences().remove(candidate);
+                        }
                     
-                    continue;
+                        continue;
+                    }
                 }
                 
