Index: /trunk/src/org/openstreetmap/josm/command/Command.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/command/Command.java	(revision 5758)
+++ /trunk/src/org/openstreetmap/josm/command/Command.java	(revision 5759)
@@ -1,6 +1,4 @@
 //License: GPL. Copyright 2007 by Immanuel Scholz and others
 package org.openstreetmap.josm.command;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
 
 import java.awt.GridBagLayout;
@@ -16,6 +14,4 @@
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.MutableTreeNode;
 
 import org.openstreetmap.josm.Main;
@@ -59,8 +55,11 @@
 
     /** the layer which this command is applied to */
-    private OsmDataLayer layer;
-
+    private final OsmDataLayer layer;
+
+    /**
+     * Creates a new command in the context of the current edit layer, if any
+     */
     public Command() {
-        this.layer = Main.map.mapView.getEditLayer();
+        this.layer = Main.map != null && Main.map.mapView != null ? Main.map.mapView.getEditLayer() : null;
     }
 
@@ -79,4 +78,5 @@
      * Executes the command on the dataset. This implementation will remember all
      * primitives returned by fillModifiedData for restoring them on undo.
+     * @return true
      */
     public boolean executeCommand() {
@@ -124,13 +124,9 @@
      * Lets other commands access the original version
      * of the object. Usually for undoing.
+     * @param osm The requested OSM object
+     * @return The original version of the requested object, if any
      */
     public PrimitiveData getOrig(OsmPrimitive osm) {
-        PrimitiveData o = cloneMap.get(osm);
-        if (o != null)
-            return o;
-        for (OsmPrimitive t : cloneMap.keySet()) {
-            PrimitiveData to = cloneMap.get(t);
-        }
-        return o;
+        return cloneMap.get(osm);
     }
 
