Index: trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDcleanupKeyInteractions.java
===================================================================
--- trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDcleanupKeyInteractions.java	(revision 751)
+++ 	(revision )
@@ -1,95 +1,0 @@
-
-package de.ugoe.cs.quest.commands.sequences;
-
-import java.security.InvalidParameterException;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.logging.Level;
-
-import de.ugoe.cs.quest.CommandHelpers;
-import de.ugoe.cs.quest.SequenceInstanceOf;
-import de.ugoe.cs.quest.eventcore.Event;
-import de.ugoe.cs.quest.eventcore.gui.KeyInteractionCleaner;
-import de.ugoe.cs.quest.eventcore.gui.KeyInteractionCleaner.CleanupMode;
-import de.ugoe.cs.util.console.Command;
-import de.ugoe.cs.util.console.Console;
-import de.ugoe.cs.util.console.GlobalDataContainer;
-
-/**
- * <p>
- * TODO comment
- * </p>
- * 
- * @version $Revision: $ $Date: Sep 3, 2012$
- * @author 2012, last modified by $Author: sherbold$
- */
-public class CMDcleanupKeyInteractions implements Command {
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see de.ugoe.cs.util.console.Command#run(java.util.List)
-     */
-    @SuppressWarnings("unchecked")
-    @Override
-    public void run(List<Object> parameters) {
-        String sequencesName = null;
-        String newSequencesName = null;
-        String modeString = null;
-        if (parameters.size() > 2) {
-            sequencesName = (String) parameters.get(0);
-            newSequencesName = (String) parameters.get(1);
-            modeString = (String) parameters.get(2);
-        }
-        else {
-            throw new InvalidParameterException();
-        }
-
-        Collection<List<Event>> sequences = null;
-        Object dataObject = GlobalDataContainer.getInstance().getData(sequencesName);
-        if (dataObject == null) {
-            CommandHelpers.objectNotFoundMessage(sequencesName);
-            return;
-        }
-        if (!SequenceInstanceOf.isCollectionOfSequences(dataObject)) {
-            CommandHelpers.objectNotType(sequencesName, "Collection<List<Event>>");
-            return;
-        }
-        sequences = (Collection<List<Event>>) dataObject;
-
-        KeyInteractionCleaner.CleanupMode mode = null;
-        try {
-            mode = CleanupMode.valueOf(modeString);
-        }
-        catch (IllegalArgumentException e) {
-            Console.printerrln("Invalid mode. Only REMOVAL and ADDITION are allowed values!");
-            return;
-        }
-
-        Collection<List<Event>> newSequences = new LinkedList<List<Event>>();
-        KeyInteractionCleaner cleaner = new KeyInteractionCleaner();
-
-        int i=0;
-        for (List<Event> sequence : sequences) {
-            Console.traceln(Level.INFO, "Cleaning up sequence " + i++);
-            newSequences.add(cleaner.cleanupKeyInteractions(sequence, mode));
-        }
-
-        if (GlobalDataContainer.getInstance().addData(newSequencesName, newSequences)) {
-            CommandHelpers.dataOverwritten(newSequencesName);
-        }
-
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see de.ugoe.cs.util.console.Command#help()
-     */
-    @Override
-    public String help() {
-        return "cleanupKeyInteractions <sequencesName> <newSequencesName> <mode>";
-    }
-
-}
Index: trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDsortKeyInteractions.java
===================================================================
--- trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDsortKeyInteractions.java	(revision 751)
+++ trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDsortKeyInteractions.java	(revision 765)
@@ -6,21 +6,24 @@
 import java.util.LinkedList;
 import java.util.List;
+import java.util.logging.Level;
 
 import de.ugoe.cs.quest.CommandHelpers;
 import de.ugoe.cs.quest.SequenceInstanceOf;
 import de.ugoe.cs.quest.eventcore.Event;
-import de.ugoe.cs.quest.eventcore.gui.SortedInteractionEventList;
+import de.ugoe.cs.quest.eventcore.gui.KeyInteractionSorter;
+import de.ugoe.cs.quest.eventcore.gui.KeyInteractionSorter.CleanupMode;
 import de.ugoe.cs.util.console.Command;
+import de.ugoe.cs.util.console.Console;
 import de.ugoe.cs.util.console.GlobalDataContainer;
 
 /**
  * <p>
- * Command to sort the key interactions in a sequence of events. An example, the sequence
- * to write the upper case D
+ * Command to sort the key interactions in a sequence of events. An example, the sequence to write
+ * the upper case D
  * <ul>
- *   <li>press shift key</li>
- *   <li>press D key</li>
- *   <li>release shift key</li>
- *   <li>release D key</li>
+ * <li>press shift key</li>
+ * <li>press D key</li>
+ * <li>release shift key</li>
+ * <li>release D key</li>
  * </ul>
  * 
@@ -28,12 +31,12 @@
  * 
  * <ul>
- *   <li>press shift key</li>
- *   <li>press D key</li>
- *   <li>release D key</li>
- *   <li>release shift key</li>
+ * <li>press shift key</li>
+ * <li>press D key</li>
+ * <li>release D key</li>
+ * <li>release shift key</li>
  * </ul>
  * 
- * in which the first pressed key (shift in this case) is always released last. The same is done
- * for the alt and the ctrl keys.
+ * in which the first pressed key (shift in this case) is always released last. The same is done for
+ * the alt and the ctrl keys.
  * 
  * </p>
@@ -64,4 +67,5 @@
         String sequencesName;
         String newSequencesName;
+        String modeString = "ADDITION";
         try {
             sequencesName = (String) parameters.get(0);
@@ -71,4 +75,7 @@
             else {
                 newSequencesName = sequencesName;
+            }
+            if (parameters.size() > 2) {
+                modeString = (String) parameters.get(2);
             }
         }
@@ -88,17 +95,21 @@
         }
 
+        CleanupMode mode = null;
+        try {
+            mode = CleanupMode.valueOf(modeString);
+        }
+        catch (IllegalArgumentException e) {
+            Console.printerrln("Invalid mode. Only REMOVAL and ADDITION are allowed values!");
+            return;
+        }
+
         sequences = (Collection<List<Event>>) dataObject;
-        SortedInteractionEventList sortedEventList;
 
         Collection<List<Event>> newSequences = new LinkedList<List<Event>>();
-        
+
+        int i = 1;
         for (List<Event> sequence : sequences) {
-            sortedEventList = new SortedInteractionEventList();
-            
-            for (Event event : sequence) {
-                sortedEventList.add(event);
-            }
-            
-            newSequences.add(sortedEventList);
+            Console.traceln(Level.INFO, "Processing sequence " + i++);
+            newSequences.add(new KeyInteractionSorter(mode).sortKeyInteractions(sequence));
         }
 
@@ -106,5 +117,5 @@
             CommandHelpers.dataOverwritten(newSequencesName);
         }
-        
+
     }
 
Index: trunk/quest-ui-core/src/main/resources/manuals/cleanupKeyInteractions
===================================================================
--- trunk/quest-ui-core/src/main/resources/manuals/cleanupKeyInteractions	(revision 751)
+++ 	(revision )
@@ -1,10 +1,0 @@
-Deletes an object, e.g., a selection of sequences, from the global data storage.
-
-$USAGE$
-<sequencesName> name of the sequences to be cleaned-up
-<neqSequencesName> name of the cleaned-up sequences
-<mode> defines whether KeyReleased events without a matching KeyPressed are removed (mode: REMOVAL) or if a matching KeyPressed event is added directly in front of the KeyReleased event (mode: ADDITION)
-
-Example(s):
-cleanupKeyInteractions sequences cleanedSequences REMOVAL
-cleanupKeyInteractions sequences cleanedSequences ADDITION
