Index: /trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java	(revision 1286)
+++ /trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java	(revision 1287)
@@ -34,4 +34,5 @@
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.mapmode.SelectAction;
 import org.openstreetmap.josm.command.AddCommand;
 import org.openstreetmap.josm.command.ChangeCommand;
@@ -167,4 +168,5 @@
         boolean newNode = false;
         Node n = null;
+        boolean wayIsFinished = false;
 
         if (!ctrl) {
@@ -280,6 +282,14 @@
             // existing way or make a new way of its own? The "alt" modifier means that the
             // user wants a new way.
-
             Way way = alt ? null : (selectedWay != null) ? selectedWay : getWayForNode(n0);
+
+            // Don't allow creation of self-overlapping ways
+            if(way != null) {
+                int nodeCount=0;
+                for (Node p : way.nodes) 
+                    if(p.equals(n0)) nodeCount++;
+                if(nodeCount > 1) way = null;
+            }
+
             if (way == null) {
                 way = new Way();
@@ -297,4 +307,13 @@
             }
 
+            // Connected to a node that's already in the way
+            if(way != null && way.nodes.contains(n)) {
+                System.out.println("Stop drawing, node is part of current way");
+                wayIsFinished = true;
+                selection.clear();
+                //Main.map.selectMapMode(new SelectAction(Main.map));
+            }
+            
+            // Add new node to way
             if (way.nodes.get(way.nodes.size() - 1) == n0) {
                 way.nodes.add(n);
@@ -329,5 +348,5 @@
 
         Main.main.undoRedo.add(c);
-        lastUsedNode = n;
+        if(!wayIsFinished) lastUsedNode = n;
         computeHelperLine();
         Main.map.mapView.repaint();
