Index: trunk/src/org/openstreetmap/josm/actions/mapmode/AddNodeAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/mapmode/AddNodeAction.java	(revision 350)
+++ trunk/src/org/openstreetmap/josm/actions/mapmode/AddNodeAction.java	(revision 351)
@@ -150,5 +150,5 @@
 					return;
 			} 
-			// If ALT is held, instead of creating a new node, re-use an existing
+			// If SHIFT is held, instead of creating a new node, re-use an existing
 			// node (making this action identical to AddSegmentAction with the
 			// small difference that the node used will then be selected to allow
@@ -191,6 +191,8 @@
 					cmds.add(new AddCommand(way));
 				} else {
-					if (insertInto != null && way == insertInto.way) {
-						way = newInsertInto;
+					if (insertInto != null) {
+						if (way == insertInto.way) {
+							way = newInsertInto;
+						}
 					} else {
 						Way wnew = new Way(way);
@@ -222,12 +224,12 @@
 		Way way = null;
 		for (Way w : Main.ds.ways) {
+			if (w.nodes.size() < 1) continue;
 			int i = w.nodes.indexOf(n);
-			if (i == -1) continue;
-			if (i == 0 || i == w.nodes.size() - 1) {
-					if (way != null)
-						return null;
-					way = w;
-				}
+			if (w.nodes.get(0) == n || w.nodes.get(w.nodes.size() - 1) == n) {
+				if (way != null)
+					return null;
+				way = w;
 			}
+		}
 		return way;
 	}
