Index: /trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java	(revision 12064)
+++ /trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java	(revision 12065)
@@ -715,25 +715,29 @@
             if (startEN == null) return false; // fix #8128
             ds.beginUpdate();
-            if (c instanceof MoveCommand && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) {
-                ((MoveCommand) c).saveCheckpoint();
-                ((MoveCommand) c).applyVectorTo(currentEN);
-            } else {
-                c = new MoveCommand(selection, startEN, currentEN);
-                Main.main.undoRedo.add(c);
-            }
-            for (Node n : affectedNodes) {
-                LatLon ll = n.getCoor();
-                if (ll != null && ll.isOutSideWorld()) {
-                    // Revert move
-                    ((MoveCommand) c).resetToCheckpoint();
-                    ds.endUpdate();
-                    JOptionPane.showMessageDialog(
-                            Main.parent,
-                            tr("Cannot move objects outside of the world."),
-                            tr("Warning"),
-                            JOptionPane.WARNING_MESSAGE);
-                    mv.setNewCursor(cursor, this);
-                    return false;
-                }
+            try {
+                if (c instanceof MoveCommand && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) {
+                    ((MoveCommand) c).saveCheckpoint();
+                    ((MoveCommand) c).applyVectorTo(currentEN);
+                } else {
+                    c = new MoveCommand(selection, startEN, currentEN);
+                    Main.main.undoRedo.add(c);
+                }
+                for (Node n : affectedNodes) {
+                    LatLon ll = n.getCoor();
+                    if (ll != null && ll.isOutSideWorld()) {
+                        // Revert move
+                        ((MoveCommand) c).resetToCheckpoint();
+                        // TODO: We might use a simple notification in the lower left corner.
+                        JOptionPane.showMessageDialog(
+                                Main.parent,
+                                tr("Cannot move objects outside of the world."),
+                                tr("Warning"),
+                                JOptionPane.WARNING_MESSAGE);
+                        mv.setNewCursor(cursor, this);
+                        return false;
+                    }
+                }
+            } finally {
+                ds.endUpdate();
             }
         } else {
@@ -745,25 +749,27 @@
 
             ds.beginUpdate();
-
-            if (mode == Mode.ROTATE) {
-                if (c instanceof RotateCommand && affectedNodes.equals(((RotateCommand) c).getTransformedNodes())) {
-                    ((RotateCommand) c).handleEvent(currentEN);
-                } else {
-                    Main.main.undoRedo.add(new RotateCommand(selection, currentEN));
-                }
-            } else if (mode == Mode.SCALE) {
-                if (c instanceof ScaleCommand && affectedNodes.equals(((ScaleCommand) c).getTransformedNodes())) {
-                    ((ScaleCommand) c).handleEvent(currentEN);
-                } else {
-                    Main.main.undoRedo.add(new ScaleCommand(selection, currentEN));
-                }
-            }
-
-            Collection<Way> ways = ds.getSelectedWays();
-            if (doesImpactStatusLine(affectedNodes, ways)) {
-                Main.map.statusLine.setDist(ways);
-            }
-        }
-        ds.endUpdate();
+            try {
+                if (mode == Mode.ROTATE) {
+                    if (c instanceof RotateCommand && affectedNodes.equals(((RotateCommand) c).getTransformedNodes())) {
+                        ((RotateCommand) c).handleEvent(currentEN);
+                    } else {
+                        Main.main.undoRedo.add(new RotateCommand(selection, currentEN));
+                    }
+                } else if (mode == Mode.SCALE) {
+                    if (c instanceof ScaleCommand && affectedNodes.equals(((ScaleCommand) c).getTransformedNodes())) {
+                        ((ScaleCommand) c).handleEvent(currentEN);
+                    } else {
+                        Main.main.undoRedo.add(new ScaleCommand(selection, currentEN));
+                    }
+                }
+
+                Collection<Way> ways = ds.getSelectedWays();
+                if (doesImpactStatusLine(affectedNodes, ways)) {
+                    Main.map.statusLine.setDist(ways);
+                }
+            } finally {
+                ds.endUpdate();
+            }
+        }
         return true;
     }
@@ -907,12 +913,15 @@
             Command c = getLastCommandInDataset(ds);
             ds.beginUpdate();
-            if (c instanceof MoveCommand && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) {
-                Node selectedNode = selNodes.iterator().next();
-                EastNorth selectedEN = selectedNode.getEastNorth();
-                EastNorth targetEN = target.getEastNorth();
-                ((MoveCommand) c).moveAgain(targetEN.getX() - selectedEN.getX(),
-                                            targetEN.getY() - selectedEN.getY());
-            }
-            ds.endUpdate();
+            try {
+                if (c instanceof MoveCommand && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) {
+                    Node selectedNode = selNodes.iterator().next();
+                    EastNorth selectedEN = selectedNode.getEastNorth();
+                    EastNorth targetEN = target.getEastNorth();
+                    ((MoveCommand) c).moveAgain(targetEN.getX() - selectedEN.getX(),
+                                                targetEN.getY() - selectedEN.getY());
+                }
+            } finally {
+                ds.endUpdate();
+            }
         }
 
Index: /trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/DataSet.java	(revision 12064)
+++ /trunk/src/org/openstreetmap/josm/data/osm/DataSet.java	(revision 12065)
@@ -1228,6 +1228,6 @@
     public void invalidateEastNorthCache() {
         if (Main.getProjection() == null) return; // sanity check
+        beginUpdate();
         try {
-            beginUpdate();
             for (Node n: getNodes()) {
                 n.invalidateEastNorthCache();
Index: /trunk/src/org/openstreetmap/josm/gui/MapStatus.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/MapStatus.java	(revision 12064)
+++ /trunk/src/org/openstreetmap/josm/gui/MapStatus.java	(revision 12065)
@@ -293,18 +293,18 @@
                 boolean isAtOldPosition = mouseNotMoved && popup != null;
                 boolean middleMouseDown = (ms.modifiers & MouseEvent.BUTTON2_DOWN_MASK) != 0;
+
+                ds = mv.getLayerManager().getEditDataSet();
+                if (ds != null) {
+                    // This is not perfect, if current dataset was changed during execution, the lock would be useless
+                    if (isAtOldPosition && middleMouseDown) {
+                        // Write lock is necessary when selecting in popupCycleSelection
+                        // locks can not be upgraded -> if do read lock here and write lock later
+                        // (in OsmPrimitive.updateFlags) then always occurs deadlock (#5814)
+                        ds.beginUpdate();
+                    } else {
+                        ds.getReadLock().lock();
+                    }
+                }
                 try {
-                    ds = mv.getLayerManager().getEditDataSet();
-                    if (ds != null) {
-                        // This is not perfect, if current dataset was changed during execution, the lock would be useless
-                        if (isAtOldPosition && middleMouseDown) {
-                            // Write lock is necessary when selecting in popupCycleSelection
-                            // locks can not be upgraded -> if do read lock here and write lock later
-                            // (in OsmPrimitive.updateFlags) then always occurs deadlock (#5814)
-                            ds.beginUpdate();
-                        } else {
-                            ds.getReadLock().lock();
-                        }
-                    }
-
                     // Set the text label in the bottom status bar
                     // "if mouse moved only" was added to stop heap growing
Index: /trunk/src/org/openstreetmap/josm/io/AbstractReader.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/AbstractReader.java	(revision 12064)
+++ /trunk/src/org/openstreetmap/josm/io/AbstractReader.java	(revision 12065)
@@ -194,6 +194,6 @@
 
     protected final void prepareDataSet() throws IllegalDataException {
+        ds.beginUpdate();
         try {
-            ds.beginUpdate();
             processNodesAfterParsing();
             processWaysAfterParsing();
