Index: trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java	(revision 8849)
+++ trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java	(revision 8850)
@@ -255,12 +255,11 @@
                 wayDataList.get(0).calcDirections(Direction.RIGHT);
                 double refHeading = wayDataList.get(0).heading;
+                EastNorth totSum = new EastNorth(0., 0.);
                 for (WayData w : wayDataList) {
                     w.calcDirections(Direction.RIGHT);
                     int directionOffset = angleToDirectionChange(w.heading - refHeading, TOLERANCE2);
                     w.calcDirections(Direction.RIGHT.changeBy(directionOffset));
-                    if (angleToDirectionChange(refHeading - w.heading, TOLERANCE2) != 0) throw new RuntimeException();
-                }
-                EastNorth totSum = new EastNorth(0., 0.);
-                for (WayData w : wayDataList) {
+                    if (angleToDirectionChange(refHeading - w.heading, TOLERANCE2) != 0)
+                        throw new RuntimeException();
                     totSum = EN.sum(totSum, w.segSum);
                 }
@@ -343,12 +342,10 @@
                     }
                 }
+
+                final Map<Node, Double> nC = (orientation == HORIZONTAL) ? nY : nX;
+
+                double average = 0;
                 for (Node n : cs) {
                     s.remove(n);
-                }
-
-                final Map<Node, Double> nC = (orientation == HORIZONTAL) ? nY : nX;
-
-                double average = 0;
-                for (Node n : cs) {
                     average += nC.get(n).doubleValue();
                 }
Index: trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java	(revision 8849)
+++ trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java	(revision 8850)
@@ -652,6 +652,4 @@
             for (int i : is) {
                 segSet.add(Pair.sort(new Pair<>(w.getNode(i), w.getNode(i+1))));
-            }
-            for (int i : is) {
                 wnew.addNode(i + 1, n);
             }
Index: trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateRelation.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateRelation.java	(revision 8849)
+++ trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateRelation.java	(revision 8850)
@@ -243,13 +243,4 @@
         long idToKeep = 0;
         Relation relationToKeep = relFix.iterator().next();
-        // Only one relation will be kept - the one with lowest positive ID, if such exist
-        // or one "at random" if no such exists. Rest of the relations will be deleted
-        for (Relation w: relFix) {
-            if (!w.isNew() && (idToKeep == 0 || w.getId() < idToKeep)) {
-                idToKeep = w.getId();
-                relationToKeep = w;
-            }
-        }
-
         // Find the relation that is member of one or more relations. (If any)
         Relation relationWithRelations = null;
@@ -262,4 +253,10 @@
                 relationWithRelations = w;
                 relRef = rel;
+            }
+            // Only one relation will be kept - the one with lowest positive ID, if such exist
+            // or one "at random" if no such exists. Rest of the relations will be deleted
+            if (!w.isNew() && (idToKeep == 0 || w.getId() < idToKeep)) {
+                idToKeep = w.getId();
+                relationToKeep = w;
             }
         }
Index: trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java	(revision 8849)
+++ trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java	(revision 8850)
@@ -253,13 +253,4 @@
         long idToKeep = 0;
         Way wayToKeep = ways.iterator().next();
-        // Only one way will be kept - the one with lowest positive ID, if such exist
-        // or one "at random" if no such exists. Rest of the ways will be deleted
-        for (Way w: ways) {
-            if (!w.isNew() && (idToKeep == 0 || w.getId() < idToKeep)) {
-                idToKeep = w.getId();
-                wayToKeep = w;
-            }
-        }
-
         // Find the way that is member of one or more relations. (If any)
         Way wayWithRelations = null;
@@ -273,4 +264,10 @@
                 relations = rel;
             }
+            // Only one way will be kept - the one with lowest positive ID, if such exist
+            // or one "at random" if no such exists. Rest of the ways will be deleted
+            if (!w.isNew() && (idToKeep == 0 || w.getId() < idToKeep)) {
+                idToKeep = w.getId();
+                wayToKeep = w;
+            }
         }
 
Index: trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java	(revision 8849)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java	(revision 8850)
@@ -259,7 +259,4 @@
                     }
                 }
-            }
-
-            for (SourceEntry def : defaults) {
                 knownDefaults.add(def.url);
             }
Index: trunk/src/org/openstreetmap/josm/io/session/SessionReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/session/SessionReader.java	(revision 8849)
+++ trunk/src/org/openstreetmap/josm/io/session/SessionReader.java	(revision 8850)
@@ -503,13 +503,6 @@
                 }
             }
-        }
-        for (Entry<Integer, Layer> e : layersMap.entrySet()) {
-            Layer l = e.getValue();
-            if (l == null) {
-                continue;
-            }
-
-            l.setName(names.get(e.getKey()));
-            layers.add(l);
+            layer.setName(names.get(entry.getKey()));
+            layers.add(layer);
         }
     }
