Index: /applications/editors/josm/plugins/CommandLine/src/CommandLine/AnyAction.java
===================================================================
--- /applications/editors/josm/plugins/CommandLine/src/CommandLine/AnyAction.java	(revision 32415)
+++ /applications/editors/josm/plugins/CommandLine/src/CommandLine/AnyAction.java	(revision 32416)
@@ -19,4 +19,5 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.mapmode.MapMode;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.gui.MapFrame;
@@ -77,17 +78,17 @@
         processMouseEvent(e);
         if (nearestPrimitive != null) {
+            DataSet ds = Main.getLayerManager().getEditDataSet();
             if (isCtrlDown) {
-                Main.main.getCurrentDataSet().clearSelection(nearestPrimitive);
+                ds.clearSelection(nearestPrimitive);
                 Main.map.mapView.repaint();
-            }
-            else {
+            } else {
                 int maxInstances = parentPlugin.currentCommand.parameters.get(parentPlugin.currentCommand.currentParameterNum).maxInstances;
                 switch (maxInstances) {
                 case 0:
-                    Main.main.getCurrentDataSet().addSelected(nearestPrimitive);
+                    ds.addSelected(nearestPrimitive);
                     Main.map.mapView.repaint();
                     break;
                 case 1:
-                    Main.main.getCurrentDataSet().addSelected(nearestPrimitive);
+                    ds.addSelected(nearestPrimitive);
                     Main.map.mapView.repaint();
                     parentPlugin.loadParameter(nearestPrimitive, true);
@@ -95,6 +96,6 @@
                     break;
                 default:
-                    if (Main.main.getCurrentDataSet().getSelected().size() < maxInstances) {
-                        Main.main.getCurrentDataSet().addSelected(nearestPrimitive);
+                    if (ds.getSelected().size() < maxInstances) {
+                        ds.addSelected(nearestPrimitive);
                         Main.map.mapView.repaint();
                     }
Index: /applications/editors/josm/plugins/CommandLine/src/CommandLine/CommandLine.java
===================================================================
--- /applications/editors/josm/plugins/CommandLine/src/CommandLine/CommandLine.java	(revision 32415)
+++ /applications/editors/josm/plugins/CommandLine/src/CommandLine/CommandLine.java	(revision 32416)
@@ -121,5 +121,5 @@
                         case SELECTION:
                             if (currentMapFrame.mapMode instanceof WayAction || currentMapFrame.mapMode instanceof NodeAction || currentMapFrame.mapMode instanceof RelationAction || currentMapFrame.mapMode instanceof AnyAction) {
-                                Collection<OsmPrimitive> selected = Main.main.getCurrentDataSet().getSelected();
+                                Collection<OsmPrimitive> selected = Main.getLayerManager().getEditDataSet().getSelected();
                                 if (selected.size() > 0)
                                     loadParameter(selected, true);
@@ -214,5 +214,5 @@
         if (Main.map == null)
             return;
-        DataSet ds = Main.main.getCurrentDataSet();
+        DataSet ds = Main.getLayerManager().getEditDataSet();
         if (ds == null)
             return;
@@ -323,5 +323,5 @@
 
     protected void setMode(Mode targetMode) {
-        DataSet currentDataSet = Main.main.getCurrentDataSet();
+        DataSet currentDataSet = Main.getLayerManager().getEditDataSet();
         if (currentDataSet != null) {
             currentDataSet.clearSelection();
@@ -617,5 +617,5 @@
 
         // Read stdout stream
-        final DataSet currentDataSet = Main.main.getCurrentDataSet();
+        final DataSet currentDataSet = Main.getLayerManager().getEditDataSet();
         final CommandLine that = this;
         Thread osmParseThread = new Thread(new Runnable() {
Index: /applications/editors/josm/plugins/CommandLine/src/CommandLine/NodeAction.java
===================================================================
--- /applications/editors/josm/plugins/CommandLine/src/CommandLine/NodeAction.java	(revision 32415)
+++ /applications/editors/josm/plugins/CommandLine/src/CommandLine/NodeAction.java	(revision 32416)
@@ -1,7 +1,7 @@
 /*
  *      NodeAction.java
- *      
+ *
  *      Copyright 2011 Hind <foxhind@gmail.com>
- *      
+ *
  */
 
@@ -19,4 +19,5 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.mapmode.MapMode;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -25,5 +26,5 @@
 
 public class NodeAction extends MapMode implements AWTEventListener {
-	private CommandLine parentPlugin;
+    private final CommandLine parentPlugin;
     final private Cursor cursorNormal, cursorActive;
     private Cursor currentCursor;
@@ -33,15 +34,15 @@
     // private Type type;
 
-	public NodeAction(MapFrame mapFrame, CommandLine parentPlugin) {
-		super(null, "addsegment.png", null, mapFrame, ImageProvider.getCursor("normal", "selection"));
-		this.parentPlugin = parentPlugin;
-		cursorNormal = ImageProvider.getCursor("normal", "selection");
-		cursorActive = ImageProvider.getCursor("normal", "joinnode");
+    public NodeAction(MapFrame mapFrame, CommandLine parentPlugin) {
+        super(null, "addsegment.png", null, mapFrame, ImageProvider.getCursor("normal", "selection"));
+        this.parentPlugin = parentPlugin;
+        cursorNormal = ImageProvider.getCursor("normal", "selection");
+        cursorActive = ImageProvider.getCursor("normal", "joinnode");
         currentCursor = cursorNormal;
         nearestNode = null;
-	}
+    }
 
-	@Override public void enterMode() {
-		super.enterMode();
+    @Override public void enterMode() {
+        super.enterMode();
         currentCursor = cursorNormal;
         Main.map.mapView.addMouseListener(this);
@@ -51,9 +52,9 @@
         } catch (SecurityException ex) {
         }
-	}
+    }
 
-	@Override public void exitMode() {
-		super.exitMode();
-		Main.map.mapView.removeMouseListener(this);
+    @Override public void exitMode() {
+        super.exitMode();
+        Main.map.mapView.removeMouseListener(this);
         Main.map.mapView.removeMouseMotionListener(this);
         try {
@@ -61,5 +62,5 @@
         } catch (SecurityException ex) {
         }
-	}
+    }
 
     @Override
@@ -79,38 +80,39 @@
         processMouseEvent(e);
         if (nearestNode != null) {
-			if (isCtrlDown) {
-				Main.main.getCurrentDataSet().clearSelection(nearestNode);
-				Main.map.mapView.repaint();
-			}
-			else {
-				int maxInstances = parentPlugin.currentCommand.parameters.get(parentPlugin.currentCommand.currentParameterNum).maxInstances;
-				switch (maxInstances) {
-				case 0:
-					Main.main.getCurrentDataSet().addSelected(nearestNode);
-					Main.map.mapView.repaint();
-					break;
-				case 1:
-					Main.main.getCurrentDataSet().addSelected(nearestNode);
-					Main.map.mapView.repaint();
-					parentPlugin.loadParameter(nearestNode, true);
-					exitMode();
-					break;
-				default:
-					if (Main.main.getCurrentDataSet().getSelected().size() < maxInstances) {
-						Main.main.getCurrentDataSet().addSelected(nearestNode);
-						Main.map.mapView.repaint();
-					}
-					else
-						parentPlugin.printHistory("Maximum instances is " + String.valueOf(maxInstances));
-				}
-			}
-		}
+            DataSet ds = Main.getLayerManager().getEditDataSet();
+            if (isCtrlDown) {
+                ds.clearSelection(nearestNode);
+                Main.map.mapView.repaint();
+            }
+            else {
+                int maxInstances = parentPlugin.currentCommand.parameters.get(parentPlugin.currentCommand.currentParameterNum).maxInstances;
+                switch (maxInstances) {
+                case 0:
+                    ds.addSelected(nearestNode);
+                    Main.map.mapView.repaint();
+                    break;
+                case 1:
+                    ds.addSelected(nearestNode);
+                    Main.map.mapView.repaint();
+                    parentPlugin.loadParameter(nearestNode, true);
+                    exitMode();
+                    break;
+                default:
+                    if (ds.getSelected().size() < maxInstances) {
+                        ds.addSelected(nearestNode);
+                        Main.map.mapView.repaint();
+                    }
+                    else
+                        parentPlugin.printHistory("Maximum instances is " + String.valueOf(maxInstances));
+                }
+            }
+        }
         super.mousePressed(e);
     }
 
-        @Override
-	public void eventDispatched(AWTEvent arg0) {
+    @Override
+    public void eventDispatched(AWTEvent arg0) {
         if (!(arg0 instanceof KeyEvent))
-                return;
+            return;
         KeyEvent ev = (KeyEvent) arg0;
         isCtrlDown = (ev.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0;
@@ -123,19 +125,19 @@
     private void updCursor() {
         if (mousePos != null) {
-			if (!Main.isDisplayingMapView())
-				return;
-			nearestNode = Main.map.mapView.getNearestNode(mousePos, OsmPrimitive.isUsablePredicate);
-			if (nearestNode != null) {
-				setCursor(cursorActive);
-			}
-			else {
-				setCursor(cursorNormal);
-			}
-		}
+            if (!Main.isDisplayingMapView())
+                return;
+            nearestNode = Main.map.mapView.getNearestNode(mousePos, OsmPrimitive.isUsablePredicate);
+            if (nearestNode != null) {
+                setCursor(cursorActive);
+            }
+            else {
+                setCursor(cursorNormal);
+            }
+        }
     }
 
-	private void processMouseEvent(MouseEvent e) {
-		if (e != null) { mousePos = e.getPoint(); }
-	}
+    private void processMouseEvent(MouseEvent e) {
+        if (e != null) { mousePos = e.getPoint(); }
+    }
 
     private void setCursor(final Cursor c) {
Index: /applications/editors/josm/plugins/CommandLine/src/CommandLine/OsmToCmd.java
===================================================================
--- /applications/editors/josm/plugins/CommandLine/src/CommandLine/OsmToCmd.java	(revision 32415)
+++ /applications/editors/josm/plugins/CommandLine/src/CommandLine/OsmToCmd.java	(revision 32416)
@@ -247,5 +247,5 @@
                 }
                 else if (currentPrimitive.isModified()) {
-                    cmds.add(new ChangeCommand(Main.main.getEditLayer(), targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive));
+                    cmds.add(new ChangeCommand(Main.getLayerManager().getEditLayer(), targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive));
                 }
                 else if (currentPrimitive.isNew()) {
@@ -259,5 +259,5 @@
                 }
                 else if (currentPrimitive.isModified()) {
-                    cmds.add(new ChangeCommand(Main.main.getEditLayer(), targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive));
+                    cmds.add(new ChangeCommand(Main.getLayerManager().getEditLayer(), targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive));
                 }
                 else if (currentPrimitive.isNew()) {
@@ -271,5 +271,5 @@
                 }
                 else if (currentPrimitive.isModified()) {
-                    cmds.add(new ChangeCommand(Main.main.getEditLayer(), targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive));
+                    cmds.add(new ChangeCommand(Main.getLayerManager().getEditLayer(), targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive));
                 }
                 else if (currentPrimitive.isNew()) {
Index: /applications/editors/josm/plugins/CommandLine/src/CommandLine/PointAction.java
===================================================================
--- /applications/editors/josm/plugins/CommandLine/src/CommandLine/PointAction.java	(revision 32415)
+++ /applications/editors/josm/plugins/CommandLine/src/CommandLine/PointAction.java	(revision 32416)
@@ -52,5 +52,5 @@
     @Override public void enterMode() {
         super.enterMode();
-        if (getCurrentDataSet() == null) {
+        if (getLayerManager().getEditDataSet() == null) {
             Main.map.selectSelectTool(false);
             return;
Index: /applications/editors/josm/plugins/CommandLine/src/CommandLine/WayAction.java
===================================================================
--- /applications/editors/josm/plugins/CommandLine/src/CommandLine/WayAction.java	(revision 32415)
+++ /applications/editors/josm/plugins/CommandLine/src/CommandLine/WayAction.java	(revision 32416)
@@ -19,4 +19,5 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.mapmode.MapMode;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Way;
@@ -100,17 +101,17 @@
         processMouseEvent(e);
         if (nearestWay != null) {
+            DataSet ds = Main.getLayerManager().getEditDataSet();
             if (isCtrlDown) {
-                Main.main.getCurrentDataSet().clearSelection(nearestWay);
+                ds.clearSelection(nearestWay);
                 Main.map.mapView.repaint();
-            }
-            else {
+            } else {
                 int maxInstances = parentPlugin.currentCommand.parameters.get(parentPlugin.currentCommand.currentParameterNum).maxInstances;
                 switch (maxInstances) {
                 case 0:
-                    Main.main.getCurrentDataSet().addSelected(nearestWay);
+                    ds.addSelected(nearestWay);
                     Main.map.mapView.repaint();
                     break;
                 case 1:
-                    Main.main.getCurrentDataSet().addSelected(nearestWay);
+                    ds.addSelected(nearestWay);
                     Main.map.mapView.repaint();
                     parentPlugin.loadParameter(nearestWay, true);
@@ -118,6 +119,6 @@
                     break;
                 default:
-                    if (Main.main.getCurrentDataSet().getSelected().size() < maxInstances) {
-                        Main.main.getCurrentDataSet().addSelected(nearestWay);
+                    if (ds.getSelected().size() < maxInstances) {
+                        ds.addSelected(nearestWay);
                         Main.map.mapView.repaint();
                     }
