Index: /trunk/src/org/openstreetmap/josm/actions/MoveAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/MoveAction.java	(revision 12052)
+++ /trunk/src/org/openstreetmap/josm/actions/MoveAction.java	(revision 12053)
@@ -137,5 +137,5 @@
 
         ds.beginUpdate();
-        if (c instanceof MoveCommand && ds.equals(((MoveCommand) c).getAffectedDataSet())
+        if (c instanceof MoveCommand && ds.equals(c.getAffectedDataSet())
                 && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) {
             ((MoveCommand) c).moveAgain(distx, disty);
Index: /trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java	(revision 12052)
+++ /trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java	(revision 12053)
@@ -711,5 +711,5 @@
             return false;
         }
-        Command c = getLastCommand();
+        Command c = getLastCommandInDataset(ds);
         if (mode == Mode.MOVE) {
             if (startEN == null) return false; // fix #8128
@@ -784,6 +784,7 @@
      */
     private void useLastMoveCommandIfPossible() {
-        Command c = getLastCommand();
-        Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(getLayerManager().getEditDataSet().getSelected());
+        DataSet dataSet = getLayerManager().getEditDataSet();
+        Command c = getLastCommandInDataset(dataSet);
+        Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(dataSet.getSelected());
         if (c instanceof MoveCommand && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) {
             // old command was created with different base point of movement, we need to recalculate it
@@ -794,13 +795,19 @@
     /**
      * Obtain command in undoRedo stack to "continue" when dragging
+     * @param ds The data set the command needs to be in.
      * @return last command
      */
-    private static Command getLastCommand() {
-        Command c = !Main.main.undoRedo.commands.isEmpty()
-                ? Main.main.undoRedo.commands.getLast() : null;
-        if (c instanceof SequenceCommand) {
-            c = ((SequenceCommand) c).getLastCommand();
-        }
-        return c;
+    private Command getLastCommandInDataset(DataSet ds) {
+        LinkedList<Command> commands = Main.main.undoRedo.commands;
+        if (!commands.isEmpty()) {
+            Command lastCommand = commands.getLast();
+            if (lastCommand instanceof SequenceCommand) {
+                lastCommand = ((SequenceCommand) lastCommand).getLastCommand();
+            }
+            if (ds.equals(lastCommand.getAffectedDataSet())) {
+                return lastCommand;
+            }
+        }
+        return null;
     }
 
@@ -898,8 +905,7 @@
             Collection<OsmPrimitive> selection = ds.getSelectedNodesAndWays();
             Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(selection);
-            Command c = getLastCommand();
+            Command c = getLastCommandInDataset(ds);
             ds.beginUpdate();
-            if (c instanceof MoveCommand
-                && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) {
+            if (c instanceof MoveCommand && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) {
                 Node selectedNode = selNodes.iterator().next();
                 EastNorth selectedEN = selectedNode.getEastNorth();
