Index: applications/editors/josm/plugins/utilsplugin2/build.xml
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/build.xml	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/build.xml	(revision 32333)
@@ -5,5 +5,5 @@
     <property name="commit.message" value="[josm_utilsplugin2]: select boundary by double-click; multitagger table highlights"/>
     <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
-    <property name="plugin.main.version" value="8919"/>
+    <property name="plugin.main.version" value="10420"/>
 
     <property name="plugin.author" value="Kalle Lampila, Upliner, Zverik, akks, joshdoe and others"/>
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/AddIntersectionsAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/AddIntersectionsAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/AddIntersectionsAction.java	(revision 32333)
@@ -28,4 +28,8 @@
 
 public class AddIntersectionsAction extends JosmAction {
+    
+    /**
+     * Constructs a new {@code AddIntersectionsAction}.
+     */
     public AddIntersectionsAction() {
         super(tr("Add nodes at intersections"), "addintersect", tr("Add missing nodes at intersections of selected ways."),
@@ -38,5 +42,5 @@
         if (!isEnabled())
             return;
-        List<Way> ways = OsmPrimitive.getFilteredList(getCurrentDataSet().getSelected(), Way.class);
+        List<Way> ways = OsmPrimitive.getFilteredList(getLayerManager().getEditDataSet().getSelected(), Way.class);
         if (ways.isEmpty()) {
             new Notification(
@@ -56,10 +60,11 @@
                 Collection<? extends OsmPrimitive> pp = cmd.getParticipatingPrimitives();
                 for ( OsmPrimitive p : pp) { // find all affected nodes
-                    if (p instanceof Node && p.isNew()) nodes.add((Node)p);
+                    if (p instanceof Node && p.isNew())
+                        nodes.add((Node)p);
                 }
                 if (!nodes.isEmpty()) {
-                    getCurrentDataSet().setSelected(nodes);
-                    }
+                    getLayerManager().getEditDataSet().setSelected(nodes);
                 }
+            }
         }
     }
@@ -67,9 +72,5 @@
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(getCurrentDataSet().getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/AlignWayNodesAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/AlignWayNodesAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/AlignWayNodesAction.java	(revision 32333)
@@ -22,4 +22,7 @@
     private static final double MOVE_THRESHOLD = 1e-9;
 
+    /**
+     * Constructs a new {@code AlignWayNodesAction}.
+     */
     public AlignWayNodesAction() {
         super(TITLE, "dumbutils/alignwaynodes", tr("Align nodes in a way"),
@@ -29,5 +32,5 @@
 
     public void actionPerformed( ActionEvent e ) {
-        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
+        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
         Set<Node> selectedNodes = filterNodes(selection);
         int selectedNodesCount = selectedNodes.size();
@@ -116,8 +119,5 @@
     @Override
     protected void updateEnabledState() {
-        if( getCurrentDataSet() == null ) {
-            setEnabled(false);
-        }  else
-            updateEnabledState(getCurrentDataSet().getSelected());
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/CopyTagsAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/CopyTagsAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/CopyTagsAction.java	(revision 32333)
@@ -45,6 +45,6 @@
     public void actionPerformed(ActionEvent e) {
         if (isEmptySelection()) return;
-        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
-        copy(getEditLayer(), selection);
+        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
+        copy(getLayerManager().getEditLayer(), selection);
     }
 
@@ -67,9 +67,5 @@
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(getCurrentDataSet().getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
@@ -79,6 +75,6 @@
     }
 
-    private static boolean isEmptySelection() {
-        Collection<OsmPrimitive> sel = getCurrentDataSet().getSelected();
+    private boolean isEmptySelection() {
+        Collection<OsmPrimitive> sel = getLayerManager().getEditDataSet().getSelected();
         if (sel.isEmpty()) {
             JOptionPane.showMessageDialog(
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/ExtractPointAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/ExtractPointAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/ExtractPointAction.java	(revision 32333)
@@ -25,9 +25,11 @@
 
 /**
- *    Unselects all nodes
+ * Extracts node from its ways.
  */
 public class ExtractPointAction extends JosmAction {
 
-    
+    /**
+     * Constructs a new {@code ExtractPointAction}.
+     */
     public ExtractPointAction() {
         super(tr("Extract node"), "extnode",
@@ -40,5 +42,5 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
+        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
         List<Node> selectedNodes = OsmPrimitive.getFilteredList(selection, Node.class);
         if (selectedNodes.size()!=1) {
@@ -50,7 +52,8 @@
         Node ndCopy = new Node(nd.getCoor());
         List<Command> cmds = new LinkedList<>();
-        
+
         Point p = Main.map.mapView.getMousePosition();
-        if (p!=null) cmds.add(new MoveCommand(nd,Main.map.mapView.getLatLon(p.x, p.y)));
+        if (p != null)
+            cmds.add(new MoveCommand(nd,Main.map.mapView.getLatLon(p.x, p.y)));
         List<OsmPrimitive> refs = nd.getReferrers();
         cmds.add(new AddCommand(ndCopy));
@@ -70,9 +73,5 @@
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(getCurrentDataSet().getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/PasteRelationsAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/PasteRelationsAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/PasteRelationsAction.java	(revision 32333)
@@ -37,5 +37,5 @@
     @Override
     public void actionPerformed( ActionEvent e ) {
-        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
+        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
         if( selection.isEmpty() )
             return;
@@ -43,5 +43,5 @@
         Map<Relation, String> relations = new HashMap<>();
         for( PrimitiveData pdata : Main.pasteBuffer.getDirectlyAdded() ) {
-            OsmPrimitive p = getCurrentDataSet().getPrimitiveById(pdata.getUniqueId(), pdata.getType());
+            OsmPrimitive p = getLayerManager().getEditDataSet().getPrimitiveById(pdata.getUniqueId(), pdata.getType());
             if (p != null) {
 	            for( Relation r : OsmPrimitive.getFilteredList(p.getReferrers(), Relation.class)) {
@@ -91,8 +91,5 @@
     @Override
     protected void updateEnabledState() {
-        if( getCurrentDataSet() == null ) {
-            setEnabled(false);
-        }  else
-            updateEnabledState(getCurrentDataSet().getSelected());
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SplitObjectAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SplitObjectAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SplitObjectAction.java	(revision 32333)
@@ -38,5 +38,4 @@
  * immediately.
  */
-
 public class SplitObjectAction extends JosmAction {
     /**
@@ -59,5 +58,5 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
+        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
 
         List<Node> selectedNodes = OsmPrimitive.getFilteredList(selection, Node.class);
@@ -68,5 +67,4 @@
             return;
         }
-
 
         Way selectedWay = null;
@@ -190,5 +188,4 @@
 
         List<List<Node>> wayChunks = SplitWayAction.buildSplitChunks(selectedWay, selectedNodes);
-        //        List<List<Node>> wayChunks = buildSplitChunks(selectedWay, selectedNodes);
         if (wayChunks != null) {
             // close the chunks
@@ -213,10 +210,10 @@
                 }
             }
-            SplitWayAction.SplitWayResult result = SplitWayAction.splitWay(getEditLayer(), selectedWay, wayChunks, Collections.<OsmPrimitive>emptyList());
-            //            SplitObjectResult result = splitObject(getEditLayer(),selectedWay, wayChunks);
+            SplitWayAction.SplitWayResult result = SplitWayAction.splitWay(
+                    getLayerManager().getEditLayer(), selectedWay, wayChunks, Collections.<OsmPrimitive>emptyList());
             Main.main.undoRedo.add(result.getCommand());
             if (splitWay != null)
                 Main.main.undoRedo.add(new DeleteCommand(splitWay));
-            getCurrentDataSet().setSelected(result.getNewSelection());
+            getLayerManager().getEditDataSet().setSelected(result.getNewSelection());
         }
     }
@@ -245,9 +242,5 @@
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(getCurrentDataSet().getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SplitOnIntersectionsAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SplitOnIntersectionsAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SplitOnIntersectionsAction.java	(revision 32333)
@@ -34,5 +34,5 @@
     public void actionPerformed( ActionEvent e ) {
         List<Command> list = new ArrayList<>();
-        List<Way> selectedWays = OsmPrimitive.getFilteredList(getCurrentDataSet().getSelected(), Way.class);
+        List<Way> selectedWays = OsmPrimitive.getFilteredList(getLayerManager().getEditDataSet().getSelected(), Way.class);
         Map<Way, List<Node>> splitWays = new HashMap<>();
 
@@ -79,5 +79,5 @@
                 List<OsmPrimitive> sel = new ArrayList<>(selectedWays.size());
                 sel.addAll(selectedWays);
-                SplitWayAction.SplitWayResult result = SplitWayAction.splitWay(getEditLayer(), splitWay, wayChunks, sel);
+                SplitWayAction.SplitWayResult result = SplitWayAction.splitWay(getLayerManager().getEditLayer(), splitWay, wayChunks, sel);
                 list.add(result.getCommand());
             }
@@ -86,5 +86,5 @@
         if( !list.isEmpty() ) {
             Main.main.undoRedo.add(list.size() == 1 ? list.get(0) : new SequenceCommand(TITLE, list));
-            getCurrentDataSet().clearSelection();
+            getLayerManager().getEditDataSet().clearSelection();
         }
     }
@@ -92,8 +92,5 @@
     @Override
     protected void updateEnabledState() {
-        if( getCurrentDataSet() == null ) {
-            setEnabled(false);
-        }  else
-            updateEnabledState(getCurrentDataSet().getSelected());
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SymmetryAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SymmetryAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SymmetryAction.java	(revision 32333)
@@ -35,4 +35,7 @@
 public final class SymmetryAction extends JosmAction {
 
+    /**
+     * Constructs a new {@code SymmetryAction}.
+     */
     public SymmetryAction() {
         super(tr("Symmetry"), "symmetry", tr("Mirror selected nodes and ways."),
@@ -44,5 +47,5 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        Collection<OsmPrimitive> sel = getCurrentDataSet().getSelected();
+        Collection<OsmPrimitive> sel = getLayerManager().getEditDataSet().getSelected();
         HashSet<Node> nodes = new HashSet<>();
         EastNorth p1=null,p2=null;
@@ -89,9 +92,5 @@
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(getCurrentDataSet().getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/TagBufferAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/TagBufferAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/TagBufferAction.java	(revision 32333)
@@ -30,4 +30,7 @@
     private Set<OsmPrimitive> selectionBuf = new HashSet<>();
 
+    /**
+     * Constructs a new {@code TagBufferAction}.
+     */
     public TagBufferAction() {
         super(TITLE, "dumbutils/tagbuffer", tr("Pastes tags of previously selected object(s)"),
@@ -40,5 +43,5 @@
     @Override
     public void actionPerformed( ActionEvent e ) {
-        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
+        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
         if( selection.isEmpty() )
             return;
@@ -64,10 +67,10 @@
     @Override
     protected void updateEnabledState() {
-        if( getCurrentDataSet() == null ) {
+        if( getLayerManager().getEditDataSet() == null ) {
             setEnabled(false);
             if( selectionBuf != null )
                 selectionBuf.clear();
         }  else
-            updateEnabledState(getCurrentDataSet().getSelected());
+            updateEnabledState(getLayerManager().getEditDataSet().getSelected());
     }
 
@@ -94,5 +97,5 @@
             tags.putAll(currentTags);
         }
-        if( getCurrentDataSet() != null)
+        if( getLayerManager().getEditDataSet() != null)
             rememberSelectionTags();
 
@@ -102,5 +105,5 @@
     private void rememberSelectionTags() {
         // Fix #8350 - only care about tagged objects
-        final Collection<OsmPrimitive> selectedTaggedObjects = Utils.filter(getCurrentDataSet().getSelected(), IS_TAGGED_PREDICATE);
+        final Collection<OsmPrimitive> selectedTaggedObjects = Utils.filter(getLayerManager().getEditDataSet().getSelected(), IS_TAGGED_PREDICATE);
         if( !selectedTaggedObjects.isEmpty() ) {
             currentTags.clear();
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/TagSourceAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/TagSourceAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/TagSourceAction.java	(revision 32333)
@@ -33,5 +33,5 @@
     @Override
     public void actionPerformed( ActionEvent e ) {
-        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
+        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
         if( selection.isEmpty() || source == null || source.length() == 0 )
             return;
@@ -42,10 +42,10 @@
     @Override
     protected void updateEnabledState() {
-        if( getCurrentDataSet() == null ) {
+        if( getLayerManager().getEditDataSet() == null ) {
             setEnabled(false);
             if( selectionBuf != null )
                 selectionBuf.clear();
         }  else
-            updateEnabledState(getCurrentDataSet().getSelected());
+            updateEnabledState(getLayerManager().getEditDataSet().getSelected());
     }
 
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/UnGlueRelationAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/UnGlueRelationAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/UnGlueRelationAction.java	(revision 32333)
@@ -51,5 +51,5 @@
         LinkedList<Command> cmds = new LinkedList<>();
         List<OsmPrimitive> newPrimitives = new LinkedList<>();
-        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
+        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
 
         for (OsmPrimitive p : selection) {
@@ -83,5 +83,5 @@
             //Set selection all primiteves (new and old)
             newPrimitives.addAll(selection);
-            getCurrentDataSet().setSelected(newPrimitives);
+            getLayerManager().getEditDataSet().setSelected(newPrimitives);
             Main.map.mapView.repaint();
         }
@@ -90,9 +90,5 @@
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(getCurrentDataSet().getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
@@ -101,4 +97,3 @@
         setEnabled(selection != null && !selection.isEmpty());
     }
-
 }
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/curves/CurveAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/curves/CurveAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/curves/CurveAction.java	(revision 32333)
@@ -53,8 +53,7 @@
         updatePreferences();
 
-        List<Node> selectedNodes = new ArrayList<>(getCurrentDataSet().getSelectedNodes());
-        List<Way> selectedWays = new ArrayList<>(getCurrentDataSet().getSelectedWays());
+        List<Node> selectedNodes = new ArrayList<>(getLayerManager().getEditDataSet().getSelectedNodes());
+        List<Way> selectedWays = new ArrayList<>(getLayerManager().getEditDataSet().getSelectedWays());
 
-        // Collection<Command> cmds = doSpline(selectedNodes, selectedWays);
         Collection<Command> cmds = CircleArcMaker.doCircleArc(selectedNodes, selectedWays, angleSeparation);
         if (cmds != null)
@@ -64,9 +63,5 @@
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(getCurrentDataSet().getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
@@ -75,7 +70,3 @@
         setEnabled(selection != null && !selection.isEmpty());
     }
-
-    public static void main(String[] args) {
-    }
-
 }
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/customurl/ChooseURLAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/customurl/ChooseURLAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/customurl/ChooseURLAction.java	(revision 32333)
@@ -21,25 +21,19 @@
 
     public ChooseURLAction() {
-         super(tr("Select custom URL"), "selecturl", tr("Select custom URL"),null,true,true);
+        super(tr("Select custom URL"), "selecturl", tr("Select custom URL"),null,true,true);
     }
 
     @Override
     public void actionPerformed(ActionEvent e) {
-       showConfigDialog(false);
+        showConfigDialog(false);
     }
 
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            setEnabled(true);
-        }
+        setEnabled(getLayerManager().getEditDataSet() != null);
     }
         
     public static void showConfigDialog(final boolean fast) {
-        JPanel all = new JPanel();
-        GridBagLayout layout = new GridBagLayout();
-        all.setLayout(layout);
+        JPanel all = new JPanel(new GridBagLayout());
         
         List<String> items = URLList.getURLList();
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/customurl/OpenPageAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/customurl/OpenPageAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/customurl/OpenPageAction.java	(revision 32333)
@@ -43,5 +43,5 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        Collection<OsmPrimitive> sel = getCurrentDataSet().getSelected();
+        Collection<OsmPrimitive> sel = getLayerManager().getEditDataSet().getSelected();
         OsmPrimitive p=null;
         if (sel.size()>=1) {
@@ -88,5 +88,5 @@
         }
         } catch (UnsupportedEncodingException ex) {
-            System.err.println("Encoding error");
+            Main.error(ex, "Encoding error");
             return;
         }
@@ -97,9 +97,9 @@
             OpenBrowser.displayUrl(addr);
         } catch (Exception ex) {
-            System.err.println("Can not open URL"+addr);
+            Main.error(ex, "Can not open URL " + addr);
         }
         //Collection<Command> cmds = new LinkedList<Command>();
 
-          //  cmds.add(new MoveCommand(n, -2*ne*pr, -2*nn*pr ));
+        //cmds.add(new MoveCommand(n, -2*ne*pr, -2*nn*pr ));
         //Main.main.undoRedo.add(new SequenceCommand(tr("Symmetry"), cmds));
     }
@@ -107,11 +107,5 @@
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            setEnabled(true);
-        }
+        setEnabled(getLayerManager().getEditDataSet() != null);
     }
-
-    
 }
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/latlon/LatLonAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/latlon/LatLonAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/latlon/LatLonAction.java	(revision 32333)
@@ -89,5 +89,5 @@
     @Override
     protected void updateEnabledState() {
-        setEnabled(getEditLayer() != null);
+        setEnabled(getLayerManager().getEditLayer() != null);
     }
 }
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/multitagger/MultiTagAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/multitagger/MultiTagAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/multitagger/MultiTagAction.java	(revision 32333)
@@ -16,4 +16,7 @@
     MultiTagDialog dlg;
 
+    /**
+     * Constructs a new {@code MultiTagAction}.
+     */
     public MultiTagAction() {
         super(tr("Tag multiple objects [alpha]"), (String)null, tr("Edit tags of object list in table"),
@@ -28,17 +31,16 @@
             return;
         dlg = new MultiTagDialog();
-        dlg.selectionChanged(getCurrentDataSet().getSelected());
+        dlg.selectionChanged(getLayerManager().getEditDataSet().getSelected());
         dlg.showDialog();
     }
 
-
     @Override
     protected void updateEnabledState() {
-        setEnabled(getEditLayer()!=null);
+        setEnabled(getLayerManager().getEditLayer()!=null);
     }
 
     @Override
     protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
-        setEnabled(getEditLayer()!=null);
+        setEnabled(getLayerManager().getEditLayer()!=null);
         if (dlg!=null && dlg.isVisible()) {
             dlg.selectionChanged(selection);
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/multitagger/MultiTagDialog.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/multitagger/MultiTagDialog.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/multitagger/MultiTagDialog.java	(revision 32333)
@@ -136,6 +136,6 @@
                 public void actionPerformed(ActionEvent e) {
                     if (jt.isSelected()) tableModel.shownTypes.add(type); else tableModel.shownTypes.remove(type);
-                    tableModel.updateData(Main.main.getCurrentDataSet().getSelected());
-                };
+                    tableModel.updateData(Main.getLayerManager().getEditDataSet().getSelected());
+                }
             });
             ImageProvider.get(type);
@@ -208,5 +208,5 @@
 
     private void initAutocompletion() {
-        OsmDataLayer l = Main.main.getEditLayer();
+        OsmDataLayer l = Main.getLayerManager().getEditLayer();
         AutoCompletionManager autocomplete = l.data.getAutoCompletionManager();
         for (int i=0; i<tableModel.mainTags.length; i++) {
@@ -233,5 +233,5 @@
             @Override
             public void actionPerformed(ActionEvent e) {
-                Main.main.getCurrentDataSet().setSelected(getSelectedPrimitives());
+                Main.getLayerManager().getEditDataSet().setSelected(getSelectedPrimitives());
             }
         });
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/multitagger/MultiTaggerTableModel.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/multitagger/MultiTaggerTableModel.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/multitagger/MultiTaggerTableModel.java	(revision 32333)
@@ -54,7 +54,8 @@
     public void setWatchSelection(boolean watchSelection) {
         this.watchSelection = watchSelection;
-        if (watchSelection && Main.main.hasEditLayer()) selectionChanged(Main.main.getCurrentDataSet().getSelected());
-    }
-    
+        if (watchSelection && Main.getLayerManager().getEditLayer() != null) 
+            selectionChanged(Main.getLayerManager().getEditDataSet().getSelected());
+    }
+
     @Override
     public Object getValueAt(int rowIndex, int columnIndex) {
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceGeometryAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceGeometryAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceGeometryAction.java	(revision 32333)
@@ -30,10 +30,10 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        if (getCurrentDataSet() == null) {
+        if (getLayerManager().getEditDataSet() == null) {
             return;
         }
 
         // There must be two ways selected: one with id > 0 and one new.
-        List<OsmPrimitive> selection = new ArrayList<>(getCurrentDataSet().getSelected());
+        List<OsmPrimitive> selection = new ArrayList<>(getLayerManager().getEditDataSet().getSelected());
         if (selection.size() != 2) {
             new Notification(
@@ -68,8 +68,5 @@
     @Override
     protected void updateEnabledState() {
-        if( getCurrentDataSet() == null ) {
-            setEnabled(false);
-        }  else
-            updateEnabledState(getCurrentDataSet().getSelected());
+        updateEnabledStateOnCurrentSelection();
     }
 
@@ -79,3 +76,2 @@
     }
 }
-
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceGeometryUtils.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceGeometryUtils.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceGeometryUtils.java	(revision 32333)
@@ -117,5 +117,5 @@
         // FIXME: handle different layers
         List<Command> commands = new ArrayList<>();
-        Command c = MergeNodesAction.mergeNodes(Main.main.getEditLayer(), Arrays.asList(subjectNode, referenceNode), referenceNode);
+        Command c = MergeNodesAction.mergeNodes(Main.getLayerManager().getEditLayer(), Arrays.asList(subjectNode, referenceNode), referenceNode);
         if (c == null) {
             // User canceled
@@ -204,5 +204,5 @@
         }
 
-        Main.main.getCurrentDataSet().setSelected(referenceObject);
+        Main.getLayerManager().getEditDataSet().setSelected(referenceObject);
 
         return new ReplaceGeometryCommand(
@@ -243,5 +243,5 @@
     public static ReplaceGeometryCommand buildReplaceWayCommand(Way subjectWay, Way referenceWay) {
 
-        Area a = Main.main.getCurrentDataSet().getDataSourceArea();
+        Area a = Main.getLayerManager().getEditDataSet().getDataSourceArea();
         if (!isInArea(subjectWay, a) || !isInArea(referenceWay, a)) {
             throw new ReplaceGeometryException(tr("The ways must be entirely within the downloaded area."));
@@ -260,4 +260,5 @@
         } catch (UserCancelException e) {
             // user canceled tag merge dialog
+            Main.trace(e);
             return null;
         }
@@ -358,5 +359,5 @@
 
         // Remove geometry way from selection
-        Main.main.getCurrentDataSet().clearSelection(referenceWay);
+        Main.getLayerManager().getEditDataSet().clearSelection(referenceWay);
 
         // And delete old geometry way
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceMembershipAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceMembershipAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceMembershipAction.java	(revision 32333)
@@ -37,5 +37,5 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        final Iterator<OsmPrimitive> selection = getCurrentDataSet().getSelected().iterator();
+        final Iterator<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected().iterator();
         final OsmPrimitive firstObject = selection.next();
         final OsmPrimitive secondObject = selection.next();
@@ -56,5 +56,4 @@
             )).setIcon(JOptionPane.WARNING_MESSAGE).show();
         }
-
     }
 
@@ -80,5 +79,5 @@
     @Override
     protected void updateEnabledState() {
-        updateEnabledState(getCurrentDataSet() == null ? null : getCurrentDataSet().getSelected());
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/ConnectedMatch.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/ConnectedMatch.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/ConnectedMatch.java	(revision 32333)
@@ -32,5 +32,5 @@
         Set<Node> matchedNodes = new HashSet<>();
         // find all ways that match the expression
-        Collection<Way> allWays = Main.main.getCurrentDataSet().getWays();
+        Collection<Way> allWays = Main.getLayerManager().getEditDataSet().getWays();
         for (Way way : allWays) {
             if (match.match(way)) {
@@ -39,5 +39,5 @@
         }
         // find all nodes that match the expression
-        Collection<Node> allNodes = Main.main.getCurrentDataSet().getNodes();
+        Collection<Node> allNodes = Main.getLayerManager().getEditDataSet().getNodes();
         for (Node node : allNodes) {
             if (match.match(node)) {
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/InsideMatch.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/InsideMatch.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/InsideMatch.java	(revision 32333)
@@ -32,5 +32,5 @@
         Collection<OsmPrimitive> matchedAreas = new HashSet<>();
         // find all ways that match the expression
-        Collection<Way> ways = Main.main.getCurrentDataSet().getWays();
+        Collection<Way> ways = Main.getLayerManager().getEditDataSet().getWays();
         for (Way way : ways) {
             if (match.match(way)) {
@@ -39,5 +39,5 @@
         }
         // find all relations that match the expression
-        Collection<Relation> rels = Main.main.getCurrentDataSet().getRelations();
+        Collection<Relation> rels = Main.getLayerManager().getEditDataSet().getRelations();
         for (Relation rel : rels) {
             if (match.match(rel)) {
@@ -45,5 +45,5 @@
             }
         }
-        inside = NodeWayUtils.selectAllInside(matchedAreas, Main.main.getCurrentDataSet(), false);
+        inside = NodeWayUtils.selectAllInside(matchedAreas, Main.getLayerManager().getEditDataSet(), false);
     }
 
@@ -55,4 +55,3 @@
         return inside.contains(osm);
     }
-    
 }
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/IntersectingMatch.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/IntersectingMatch.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/IntersectingMatch.java	(revision 32333)
@@ -30,5 +30,5 @@
         Collection<Way> matchedWays = new HashSet<>();
         // find all ways that match the expression
-        Collection<Way> allWays = Main.main.getCurrentDataSet().getWays();
+        Collection<Way> allWays = Main.getLayerManager().getEditDataSet().getWays();
         for (Way way : allWays) {
             if (match.match(way)) {
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/AdjacentNodesAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/AdjacentNodesAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/AdjacentNodesAction.java	(revision 32333)
@@ -33,8 +33,9 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
+        DataSet ds = getLayerManager().getEditDataSet();
+        Collection<OsmPrimitive> selection = ds.getSelected();
         Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
 
-        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class);
+        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(ds.getSelected(), Way.class);
         
         // if no nodes and no ways are selected, do nothing
@@ -61,10 +62,10 @@
             NodeWayUtils.addNodesConnectedToWays(selectedWays, newNodes);
             activeWays.clear();
-            getCurrentDataSet().setSelected(newNodes);
+            ds.setSelected(newNodes);
             return;
         }
 
         if (activeWays.isEmpty()) {
-                NodeWayUtils.addWaysConnectedToNodes(selectedNodes, activeWays);
+            NodeWayUtils.addWaysConnectedToNodes(selectedNodes, activeWays);
         }
 
@@ -88,16 +89,10 @@
          }
 
-         getCurrentDataSet().addSelected(newNodes);
-         newNodes = null;
-
+         ds.addSelected(newNodes);
     }
 
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(getCurrentDataSet().getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
@@ -110,6 +105,3 @@
         setEnabled(!selection.isEmpty());
     }
-
-
-
 }
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/AdjacentWaysAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/AdjacentWaysAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/AdjacentWaysAction.java	(revision 32333)
@@ -32,8 +32,9 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
+        DataSet ds = getLayerManager().getEditDataSet();
+        Collection<OsmPrimitive> selection = ds.getSelected();
         Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
 
-        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class);
+        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(ds.getSelected(), Way.class);
 
         // select ways attached to already selected ways
@@ -48,14 +49,10 @@
 
 //        System.out.printf("%d ways added to selection\n",newWays.size()-selectedWays.size());
-        getCurrentDataSet().setSelected(newWays);
+        ds.setSelected(newWays);
     }
 
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(getCurrentDataSet().getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
@@ -68,6 +65,3 @@
         setEnabled(!selection.isEmpty());
     }
-
-
-
 }
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/ConnectedWaysAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/ConnectedWaysAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/ConnectedWaysAction.java	(revision 32333)
@@ -29,7 +29,8 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
+        DataSet ds = getLayerManager().getEditDataSet();
+        Collection<OsmPrimitive> selection = ds.getSelected();
         Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
-        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class);
+        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(ds.getSelected(), Way.class);
 
         Set<Way> newWays = new HashSet<>();
@@ -45,15 +46,10 @@
         
 //        System.out.printf("%d ways added to selection\n",newWays.size()-selectedWays.size());
-        getCurrentDataSet().setSelected(newWays);
-
+        ds.setSelected(newWays);
     }
 
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(getCurrentDataSet().getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
@@ -66,5 +62,3 @@
         setEnabled(!selection.isEmpty());
     }
-
-
 }
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/IntersectedWaysAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/IntersectedWaysAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/IntersectedWaysAction.java	(revision 32333)
@@ -14,4 +14,5 @@
 
 import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Way;
@@ -33,5 +34,6 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class);
+        DataSet ds = getLayerManager().getEditDataSet();
+        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(ds.getSelected(), Way.class);
 
         // select ways attached to already selected ways
@@ -39,7 +41,7 @@
             Set<Way> newWays = new HashSet<>();
             NodeWayUtils.addWaysIntersectingWays(
-                    getCurrentDataSet().getWays(),
+                    ds.getWays(),
                     selectedWays, newWays);
-            getCurrentDataSet().addSelected(newWays);
+            ds.addSelected(newWays);
             return;
         } else {
@@ -48,14 +50,9 @@
                ).setIcon(JOptionPane.WARNING_MESSAGE).show();
         }
-
     }
 
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(getCurrentDataSet().getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
@@ -68,5 +65,3 @@
         setEnabled(!selection.isEmpty());
     }
-
-
 }
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/IntersectedWaysRecursiveAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/IntersectedWaysRecursiveAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/IntersectedWaysRecursiveAction.java	(revision 32333)
@@ -14,4 +14,5 @@
 
 import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Way;
@@ -34,13 +35,13 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        
-        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class);
+        DataSet ds = getLayerManager().getEditDataSet();
+        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(ds.getSelected(), Way.class);
 
         if (!selectedWays.isEmpty()) {
             Set<Way> newWays = new HashSet<>();
             NodeWayUtils.addWaysIntersectingWaysRecursively(
-                    getCurrentDataSet().getWays(),
+                    ds.getWays(),
                     selectedWays, newWays);
-            getCurrentDataSet().addSelected(newWays);
+            ds.addSelected(newWays);
         } else {
               new Notification(
@@ -48,15 +49,9 @@
                 ).setIcon(JOptionPane.WARNING_MESSAGE).show();
         }
-
     }
-
 
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(getCurrentDataSet().getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
@@ -69,5 +64,3 @@
         setEnabled(!selection.isEmpty());
     }
-
-
 }
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/MiddleNodesAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/MiddleNodesAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/MiddleNodesAction.java	(revision 32333)
@@ -35,5 +35,5 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
+        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
         Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
 
@@ -51,16 +51,10 @@
         // select only newly found nodes
         newNodes.removeAll(selectedNodes);
-        getCurrentDataSet().addSelected(newNodes);
-        newNodes = null;
-
+        getLayerManager().getEditDataSet().addSelected(newNodes);
     }
 
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(getCurrentDataSet().getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
@@ -73,6 +67,3 @@
         setEnabled(!selection.isEmpty());
     }
-
-
-
 }
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectAllInsideAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectAllInsideAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectAllInsideAction.java	(revision 32333)
@@ -12,4 +12,5 @@
 
 import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.gui.Notification;
@@ -30,8 +31,9 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        Collection<OsmPrimitive> insideSelected = NodeWayUtils.selectAllInside(getCurrentDataSet().getSelected(), getCurrentDataSet(), true);
+        DataSet ds = getLayerManager().getEditDataSet();
+        Collection<OsmPrimitive> insideSelected = NodeWayUtils.selectAllInside(ds.getSelected(), ds, true);
         
         if (!insideSelected.isEmpty()) {
-            getCurrentDataSet().addSelected(insideSelected);
+            ds.addSelected(insideSelected);
         } else{
             new Notification(
@@ -44,9 +46,5 @@
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(getCurrentDataSet().getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectBoundaryAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectBoundaryAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectBoundaryAction.java	(revision 32333)
@@ -40,6 +40,6 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class);
-        Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Node.class);
+        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getLayerManager().getEditDataSet().getSelected(), Way.class);
+        Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(getLayerManager().getEditDataSet().getSelected(), Node.class);
         
         Set<Way> newWays = new HashSet<>();
@@ -76,5 +76,4 @@
         newWays.add(w);
         lastUsedStartingWay = w;
-        
                        
         // try going left at each turn
@@ -84,20 +83,14 @@
         
         if (!newWays.isEmpty() ) {
-            getCurrentDataSet().setSelected(newWays);
+            getLayerManager().getEditDataSet().setSelected(newWays);
         } else{
-        new Notification(
-            tr("Nothing found. Please select way that is a part of some polygon formed by connected ways")
-            ).setIcon(JOptionPane.WARNING_MESSAGE).show();            
-    }
+            new Notification(tr("Nothing found. Please select way that is a part of some polygon formed by connected ways"))
+                .setIcon(JOptionPane.WARNING_MESSAGE).show();            
+        }
     }
 
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            setEnabled(true);
-           // updateEnabledState(getCurrentDataSet().getSelected());
-        }
+        setEnabled(getLayerManager().getEditDataSet() != null);
     }
 
@@ -105,9 +98,7 @@
     protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
         if (selection == null) {
-         //   setEnabled(false);
             return;
         }
         setEnabled(true);
-        //setEnabled(!selection.isEmpty());
     }
 }
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectHighwayAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectHighwayAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectHighwayAction.java	(revision 32333)
@@ -18,4 +18,5 @@
 
 import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -40,10 +41,11 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        List<Way> selectedWays = OsmPrimitive.getFilteredList(getCurrentDataSet().getSelected(), Way.class);
+        DataSet ds = getLayerManager().getEditDataSet();
+        List<Way> selectedWays = OsmPrimitive.getFilteredList(ds.getSelected(), Way.class);
 
         if( selectedWays.size() == 1 ) {
-            getCurrentDataSet().setSelected(selectNamedRoad(selectedWays.get(0)));
+            ds.setSelected(selectNamedRoad(selectedWays.get(0)));
         } else if( selectedWays.size() == 2 ) {
-            getCurrentDataSet().setSelected(selectHighwayBetween(selectedWays.get(0), selectedWays.get(1)));
+            ds.setSelected(selectHighwayBetween(selectedWays.get(0), selectedWays.get(1)));
         } else {
             new Notification(
@@ -112,8 +114,5 @@
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null)
-            setEnabled(false);
-        else
-            updateEnabledState(getCurrentDataSet().getSelected());
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectModNodesAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectModNodesAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectModNodesAction.java	(revision 32333)
@@ -34,7 +34,8 @@
     @Override
      public void actionPerformed(ActionEvent e) {
-        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
+        DataSet ds = getLayerManager().getEditDataSet();
+        Collection<OsmPrimitive> selection = ds.getSelected();
         Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
-        getCurrentDataSet().clearSelection(selectedNodes);
+        ds.clearSelection(selectedNodes);
         Command cmd =null;
 
@@ -62,7 +63,7 @@
             }
             if (!nodes.isEmpty()) {
-                getCurrentDataSet().setSelected(nodes);
+                ds.setSelected(nodes);
                 lastCmd = cmd; // remember last used command and last selection
-                lastHash = getCurrentDataSet().getSelected().hashCode();
+                lastHash = ds.getSelected().hashCode();
                 return;
                 }
@@ -75,9 +76,5 @@
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(getCurrentDataSet().getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectModWaysAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectModWaysAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectModWaysAction.java	(revision 32333)
@@ -10,4 +10,5 @@
 import org.openstreetmap.josm.actions.JosmAction;
 import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -34,8 +35,9 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
+        DataSet ds = getLayerManager().getEditDataSet();
+        Collection<OsmPrimitive> selection = ds.getSelected();
         Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
-        getCurrentDataSet().clearSelection(selectedNodes);
-        Command cmd =null;
+        ds.clearSelection(selectedNodes);
+        Command cmd;
 
         if (Main.main.undoRedo.commands == null) return;
@@ -61,8 +63,8 @@
                 if (p instanceof Way && !p.isDeleted()) ways.add((Way)p);
             }
-            if (!ways.isEmpty() && !getCurrentDataSet().getSelected().containsAll(ways)) {
-                getCurrentDataSet().setSelected(ways);
+            if (!ways.isEmpty() && !ds.getSelected().containsAll(ways)) {
+                ds.setSelected(ways);
                 lastCmd = cmd; // remember last used command and last selection
-                lastHash = getCurrentDataSet().getSelected().hashCode();
+                lastHash = ds.getSelected().hashCode();
                 return;
                 }
@@ -74,9 +76,5 @@
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(getCurrentDataSet().getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectWayNodesAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectWayNodesAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectWayNodesAction.java	(revision 32333)
@@ -41,5 +41,5 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
+        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
 
         for (OsmPrimitive p : selection) {
@@ -60,5 +60,5 @@
         }
             
-        getCurrentDataSet().setSelected(selectedNodes);
+        getLayerManager().getEditDataSet().setSelected(selectedNodes);
         selectedNodes = null;
     }
@@ -76,9 +76,5 @@
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(getCurrentDataSet().getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/UndoSelectionAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/UndoSelectionAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/UndoSelectionAction.java	(revision 32333)
@@ -34,11 +34,10 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        LinkedList<Collection<? extends OsmPrimitive>> history
-                    = getCurrentDataSet().getSelectionHistory();
+        DataSet ds = getLayerManager().getEditDataSet();
+        LinkedList<Collection<? extends OsmPrimitive>> history = ds.getSelectionHistory();
         if (history==null || history.isEmpty()) return; // empty history
         int num=history.size();
         
-        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
-
+        Collection<OsmPrimitive> selection = ds.getSelected();
 
         if (selection!= null &&  selection.hashCode() != myAutomaticSelectionHash) {
@@ -55,11 +54,11 @@
             newsel.clear();
             newsel.addAll(histsel);
-            newsel.retainAll(getCurrentDataSet().allNonDeletedPrimitives());
+            newsel.retainAll(ds.allNonDeletedPrimitives());
             if (newsel.size() > 0 ) break;
             k++;
         } while ( k < num );
 
-        getCurrentDataSet().setSelected(newsel);
-        lastSel = getCurrentDataSet().getSelected();
+        ds.setSelected(newsel);
+        lastSel = ds.getSelected();
         myAutomaticSelectionHash = lastSel.hashCode();
         // remeber last automatic selection
@@ -68,9 +67,5 @@
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(getCurrentDataSet().getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/UnselectNodesAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/UnselectNodesAction.java	(revision 32327)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/UnselectNodesAction.java	(revision 32333)
@@ -15,9 +15,11 @@
 
 /**
- *    Unselects all nodes
+ * Unselects all nodes
  */
 public class UnselectNodesAction extends JosmAction {
 
-    
+    /**
+     * Constructs a new {@code UnselectNodesAction}.
+     */
     public UnselectNodesAction() {
         super(tr("Unselect nodes"), "unsnodes",
@@ -30,16 +32,12 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
+        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
         Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
-        getCurrentDataSet().clearSelection(selectedNodes);
+        getLayerManager().getEditDataSet().clearSelection(selectedNodes);
     }
 
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(getCurrentDataSet().getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
