Index: src/org/openstreetmap/josm/Main.java
===================================================================
--- src/org/openstreetmap/josm/Main.java	(revision 79)
+++ src/org/openstreetmap/josm/Main.java	(revision 80)
@@ -35,5 +35,4 @@
 import org.openstreetmap.josm.actions.UndoAction;
 import org.openstreetmap.josm.actions.UploadAction;
-import org.openstreetmap.josm.actions.WmsServerAction;
 import org.openstreetmap.josm.data.Preferences;
 import org.openstreetmap.josm.data.osm.DataSet;
@@ -85,5 +84,5 @@
 	private OpenAction openAction;
 	private DownloadAction downloadAction;
-    private Action wmsServerAction;
+    //private Action wmsServerAction;
 	
 	/**
@@ -102,5 +101,5 @@
 		downloadAction = new DownloadAction();
 		Action uploadAction = new UploadAction();
-		wmsServerAction = new WmsServerAction();
+		//wmsServerAction = new WmsServerAction();
         openAction = new OpenAction();
 		Action saveAction = new SaveAction();
@@ -325,8 +324,4 @@
 			mapFrame.setVisible(true);
 		}
-        //TODO: This is really hacky to unselect the action when the layer gets
-        // deleted. The whole mapView/mapFrame/layer concept needs refactoring!
-		if (mapFrame == null && (Boolean)wmsServerAction.getValue(Action.SELECTED_KEY))
-			wmsServerAction.putValue(Action.SELECTED_KEY, false);
 	}
 	/**
Index: src/org/openstreetmap/josm/gui/IconToggleButton.java
===================================================================
--- src/org/openstreetmap/josm/gui/IconToggleButton.java	(revision 79)
+++ src/org/openstreetmap/josm/gui/IconToggleButton.java	(revision 80)
@@ -21,5 +21,5 @@
 		super(action);
 		setText(null);
-		
+
 		// Tooltip
 		String toolTipText = "";
Index: src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
===================================================================
--- src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java	(revision 79)
+++ src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java	(revision 80)
@@ -7,5 +7,4 @@
 
 import javax.swing.AbstractButton;
-import javax.swing.Action;
 import javax.swing.BorderFactory;
 import javax.swing.JLabel;
@@ -53,5 +52,5 @@
 		    EventQueue.invokeLater(new Runnable(){
 		        public void run() {
-		            action.putValue(Action.SELECTED_KEY, true);
+		        	action.putValue("active", true);
 		            action.actionPerformed(null);
 		        }
Index: src/org/openstreetmap/josm/io/GpxReader.java
===================================================================
--- src/org/openstreetmap/josm/io/GpxReader.java	(revision 79)
+++ src/org/openstreetmap/josm/io/GpxReader.java	(revision 80)
@@ -8,4 +8,5 @@
 import java.io.Reader;
 import java.util.HashMap;
+import java.util.Iterator;
 
 import org.jdom.Element;
@@ -102,5 +103,5 @@
 			addNode(data, node);
 		}
-	
+
 		// read ways (and line segments)
 		for (Object wayElement : e.getChildren("trk", GPX))
@@ -112,4 +113,29 @@
 				osm.id = 0;
 		
+		// clean up the data a bit (remove broken stuff)
+		// remove line segments with from==to
+		for (Iterator<LineSegment> it = data.lineSegments.iterator(); it.hasNext();) {
+			LineSegment ls = it.next();
+			if (ls.from.equals(ls.to)) {
+				it.remove();
+				for (Way w : data.ways)
+					w.segments.remove(ls);
+			}
+		}
+		// remove double line segments (remove only subsequent doubles yet)
+		for (Iterator<Way> it = data.ways.iterator(); it.hasNext();) {
+			LineSegment ls = null;
+			for (Iterator<LineSegment> its = it.next().segments.iterator(); its.hasNext();) {
+				LineSegment cur = its.next();
+				if (ls != null && ls.equals(cur))
+					its.remove();
+				ls = cur;
+			}
+		}
+		// remove empty ways
+		for (Iterator<Way> it = data.ways.iterator(); it.hasNext();)
+			if (it.next().segments.isEmpty())
+				it.remove();
+
 		return data;
 	}
Index: src/org/openstreetmap/josm/tools/TileCache.java
===================================================================
--- src/org/openstreetmap/josm/tools/TileCache.java	(revision 79)
+++ src/org/openstreetmap/josm/tools/TileCache.java	(revision 80)
@@ -28,8 +28,8 @@
  * 
  * The tile identifier is an 32-bit integer whose bits are ordered in pairs of two.
- * If bit0 (the LSB) is 0, then the tile is right of the equator (0°). If bit1 is 0, it
- * is in the northern hemisphere. The next two bits representing the quarter within
- * the first quarter, so bit2 equals to 0 means, it is in the right half of the
- * quarter, represented by bit0 and bit1.
+ * If bit0 (the LSB) is 0, then the tile is right of the equator (0 grad). If bit1 
+ * is 0, it is in the northern hemisphere. The next two bits representing the 
+ * quarter within the first quarter, so bit2 equals to 0 means, it is in the right 
+ * half of the quarter, represented by bit0 and bit1.
  */
 public class TileCache {
