Index: /applications/editors/josm/plugins/simplifyarea/src/sk/zdila/josm/plugin/simplify/SimplifyAreaAction.java
===================================================================
--- /applications/editors/josm/plugins/simplifyarea/src/sk/zdila/josm/plugin/simplify/SimplifyAreaAction.java	(revision 30622)
+++ /applications/editors/josm/plugins/simplifyarea/src/sk/zdila/josm/plugin/simplify/SimplifyAreaAction.java	(revision 30623)
@@ -40,6 +40,4 @@
 public class SimplifyAreaAction extends JosmAction {
 
-    private static final long serialVersionUID = 6854238214548011750L;
-
     public SimplifyAreaAction() {
         super(tr("Simplify Area"), "simplify", tr("Delete unnecessary nodes from an area."),
@@ -48,9 +46,7 @@
     }
 
-
     private List<Bounds> getCurrentEditBounds() {
         return Main.main.getEditLayer().data.getDataSourceBounds();
     }
-
 
     private boolean isInBounds(final Node node, final List<Bounds> bounds) {
@@ -62,5 +58,4 @@
         return false;
     }
-
 
     private boolean confirmWayWithNodesOutsideBoundingBox() {
@@ -76,9 +71,7 @@
     }
 
-
     private void alertSelectAtLeastOneWay() {
         HelpAwareOptionPane.showOptionDialog(Main.parent, tr("Please select at least one way to simplify."), tr("Warning"), JOptionPane.WARNING_MESSAGE, null);
     }
-
 
     private boolean confirmSimplifyManyWays(final int numWays) {
@@ -90,5 +83,4 @@
         return ret == 0;
     }
-
 
     @Override
@@ -190,5 +182,4 @@
     }
 
-
     // average nearby nodes
     private Collection<Command> averageNearbyNodes(final Collection<Way> ways, final Collection<Node> nodesAlreadyDeleted) {
@@ -250,9 +241,14 @@
                     }
 
-                    final double dist = coordMap.get(n1).greatCircleDistance(coordMap.get(n2));
-                    if (dist < minDist && dist < mergeThreshold) {
-                        minDist = dist;
-                        node1 = n1;
-                        node2 = n2;
+                    final LatLon a = coordMap.get(n1);
+                    final LatLon b = coordMap.get(n2);
+                    
+                    if (a != null && b != null) {
+                        final double dist = a.greatCircleDistance(b);
+                        if (dist < minDist && dist < mergeThreshold) {
+                            minDist = dist;
+                            node1 = n1;
+                            node2 = n2;
+                        }
                     }
                 }
@@ -269,5 +265,4 @@
             }
         }
-
 
         final Collection<Command> commands = new ArrayList<Command>();
@@ -311,5 +306,4 @@
     }
 
-
     private void addNodesToDelete(final Collection<Node> nodesToDelete, final Way w) {
         final double angleThreshold = Main.pref.getDouble(SimplifyAreaPreferenceSetting.ANGLE_THRESHOLD, 10);
@@ -408,10 +402,8 @@
     }
 
-
     public static double computeConvectAngle(final LatLon coord1, final LatLon coord2, final LatLon coord3) {
         final double angle =  Math.abs(heading(coord2, coord3) - heading(coord1, coord2));
         return Math.toDegrees(angle < Math.PI ? angle : 2 * Math.PI - angle);
     }
-
 
     public static double computeArea(final LatLon coord1, final LatLon coord2, final LatLon coord3) {
@@ -426,5 +418,4 @@
     }
 
-
     public static double R = 6378135;
 
@@ -432,5 +423,4 @@
         return R * Math.asin(sin(l1.greatCircleDistance(l2) / R) * sin(heading(l1, l2) - heading(l1, l3)));
     }
-
 
     public static double heading(final LatLon a, final LatLon b) {
@@ -445,5 +435,4 @@
     }
 
-
     @Override
     protected void updateEnabledState() {
@@ -455,9 +444,7 @@
     }
 
-
     @Override
     protected void updateEnabledState(final Collection<? extends OsmPrimitive> selection) {
         setEnabled(selection != null && !selection.isEmpty());
     }
-
 }
