Index: trunk/src/org/openstreetmap/josm/actions/AlignInCircleAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/AlignInCircleAction.java	(revision 1946)
+++ trunk/src/org/openstreetmap/josm/actions/AlignInCircleAction.java	(revision 1947)
@@ -30,4 +30,5 @@
  * @author Matthew Newton
  * @author Petr Dlouhý
+ * @author Teemu Koskinen
  */
 public final class AlignInCircleAction extends JosmAction {
@@ -142,10 +143,48 @@
         }
 
+        // Reorder the nodes if they didn't come from a single way
+        if (ways.size() != 1) {
+            // First calculate the average point
+
+            BigDecimal east = new BigDecimal(0);
+            BigDecimal north = new BigDecimal(0);
+
+            for (Node n : nodes) {
+                BigDecimal x = new BigDecimal(n.getEastNorth().east());
+                BigDecimal y = new BigDecimal(n.getEastNorth().north());
+                east = east.add(x, MathContext.DECIMAL128);
+                north = north.add(y, MathContext.DECIMAL128);
+            }
+            BigDecimal nodesSize = new BigDecimal(nodes.size());
+            east = east.divide(nodesSize, MathContext.DECIMAL128);
+            north = north.divide(nodesSize, MathContext.DECIMAL128);
+
+            EastNorth average = new EastNorth(east.doubleValue(), north.doubleValue());
+            List<Node> newNodes = new LinkedList<Node>();
+
+            // Then reorder them based on heading from the average point
+            while (!nodes.isEmpty()) {
+                double maxHeading = -1.0;
+                Node maxNode = null;
+                for (Node n : nodes) {
+                    double heading = average.heading(n.getEastNorth());
+                    if (heading > maxHeading) {
+                        maxHeading = heading;
+                        maxNode = n;
+                    }
+                }
+                newNodes.add(maxNode);
+                nodes.remove(maxNode);
+            }
+
+            nodes = newNodes;
+        }
+
         if (center == null) {
             // Compute the centroid of nodes
 
-            BigDecimal area = new BigDecimal("0");
-            BigDecimal north = new BigDecimal("0");
-            BigDecimal east = new BigDecimal("0");
+            BigDecimal area = new BigDecimal(0);
+            BigDecimal north = new BigDecimal(0);
+            BigDecimal east = new BigDecimal(0);
 
             // See http://en.wikipedia.org/w/index.php?title=Centroid&oldid=294224857#Centroid_of_polygon for the equation used here
@@ -167,9 +206,8 @@
             }
 
-            BigDecimal d = new BigDecimal("2");
-            area  = area.divide(d, MathContext.DECIMAL128);
-            d = new BigDecimal("6");
-            north = north.divide(d.multiply(area, MathContext.DECIMAL128), MathContext.DECIMAL128);
-            east = east.divide(d.multiply(area, MathContext.DECIMAL128), MathContext.DECIMAL128);
+            BigDecimal d = new BigDecimal(3, MathContext.DECIMAL128); // 1/2 * 6 = 3
+            area  = area.multiply(d, MathContext.DECIMAL128);
+            north = north.divide(area, MathContext.DECIMAL128);
+            east = east.divide(area, MathContext.DECIMAL128);
 
             center = new EastNorth(east.doubleValue(), north.doubleValue());
Index: trunk/src/org/openstreetmap/josm/data/projection/Lambert.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/projection/Lambert.java	(revision 1946)
+++ trunk/src/org/openstreetmap/josm/data/projection/Lambert.java	(revision 1947)
@@ -146,5 +146,5 @@
 
     public String toCode() {
-        return "EPSG:"+(27571+currentZone-1);
+        return "EPSG:"+(27571+currentZone);
     }
 
Index: trunk/src/org/openstreetmap/josm/io/GpxWriter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/GpxWriter.java	(revision 1946)
+++ trunk/src/org/openstreetmap/josm/io/GpxWriter.java	(revision 1947)
@@ -1,4 +1,6 @@
 // License: GPL. Copyright 2007 by Immanuel Scholz and others
 package org.openstreetmap.josm.io;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
 
 import java.io.BufferedWriter;
@@ -235,8 +237,8 @@
             break;
         default:
-            throw new RuntimeException("Bug detected. Please report this!");
+            throw new RuntimeException(tr("Unknown mode {0}.", mode));
         }
         if (pnt != null) {
-            LatLon c =pnt.getCoor();
+            LatLon c = pnt.getCoor();
             openAtt(type, "lat=\"" + c.lat() + "\" lon=\"" + c.lon() + "\"");
             writeAttr(pnt.attr);
