Index: trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java	(revision 3537)
+++ trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java	(revision 3538)
@@ -193,8 +193,5 @@
     /**
      * Checks if the selection consists of something we can work with.
-     * Checks only if the number and type of items selected looks good;
-     * does not check whether the selected items are really a valid
-     * input for splitting (this would be too expensive to be carried
-     * out from the selectionChanged listener).
+     * Checks only if the number and type of items selected looks good.
      *
      * If this method returns "true", selectedNode and selectedWay will
@@ -233,8 +230,5 @@
     /**
      * Checks if the selection consists of something we can work with.
-     * Checks only if the number and type of items selected looks good;
-     * does not check whether the selected items are really a valid
-     * input for splitting (this would be too expensive to be carried
-     * out from the selectionChanged listener).
+     * Checks only if the number and type of items selected looks good.
      *
      * Returns true if one way and any number of nodes that are part of
@@ -347,17 +341,24 @@
     private void unglueWays() {
         LinkedList<Command> cmds = new LinkedList<Command>();
-        List<Node> newNodes = new LinkedList<Node>();
+        LinkedList<Node> newNodes = new LinkedList<Node>();
 
         if (selectedWay == null) {
-            boolean firstway = true;
-            // modify all ways containing the nodes
-            for (Way w : OsmPrimitive.getFilteredList(selectedNode.getReferrers(), Way.class)) {
-                if (w.isDeleted() || w.isIncomplete()) {
-                    continue;
-                }
-                if (!firstway) {
-                    cmds.add(new ChangeCommand(w, modifyWay(selectedNode, w, cmds, newNodes)));
-                }
-                firstway = false;
+            Way wayWithSelectedNode = null;
+            LinkedList<Way> parentWays = new LinkedList<Way>();
+            for (OsmPrimitive osm : selectedNode.getReferrers()) {
+                if (osm.isUsable() && osm instanceof Way) {
+                    Way w = (Way) osm;
+                    if (wayWithSelectedNode == null && !w.isFirstLastNode(selectedNode)) {
+                        wayWithSelectedNode = w;
+                    } else {
+                        parentWays.add(w);
+                    }
+                }
+            }
+            if (wayWithSelectedNode == null) {
+                wayWithSelectedNode = parentWays.removeFirst();
+            }
+            for (Way w : parentWays) {
+                cmds.add(new ChangeCommand(w, modifyWay(selectedNode, w, cmds, newNodes)));
             }
         } else {
@@ -368,8 +369,6 @@
 
         Main.main.undoRedo.add(new SequenceCommand(tr("Dupe into {0} nodes", newNodes.size()+1), cmds));
-        if (selectedWay == null) { // if a node has been selected, new selection is ALL nodes
-            newNodes.add(selectedNode);
-        } // if a node and a way has been selected, new selection is only the new node that was added to the selected way
-        getCurrentDataSet().setSelected(newNodes);
+        // select one of the new nodes
+        getCurrentDataSet().setSelected(newNodes.getFirst());
     }
 
