Index: /src/org/openstreetmap/josm/Main.java
===================================================================
--- /src/org/openstreetmap/josm/Main.java	(revision 144)
+++ /src/org/openstreetmap/josm/Main.java	(revision 145)
@@ -99,4 +99,5 @@
 	 */
 	public final void setMapFrame(final MapFrame map) {
+		MapFrame old = Main.map;
 		Main.map = map;
 		panel.setVisible(false);
@@ -126,5 +127,5 @@
 
 		for (Plugin plugin : plugins)
-			plugin.mapFrameInitialized(map);
+			plugin.mapFrameInitialized(old, map);
 	}
 
Index: /src/org/openstreetmap/josm/gui/SelectionManager.java
===================================================================
--- /src/org/openstreetmap/josm/gui/SelectionManager.java	(revision 144)
+++ /src/org/openstreetmap/josm/gui/SelectionManager.java	(revision 145)
@@ -311,8 +311,10 @@
 				if (w.deleted)
 					continue;
-				boolean wholeWaySelected = !w.segments.isEmpty();
+				boolean someSelectableSegment = false;
+				boolean wholeWaySelected = true;
 				for (Segment s : w.segments) {
 					if (s.incomplete)
 						continue;
+					someSelectableSegment = true;
 					if (!rectangleContainSegment(r, alt, s)) {
 						wholeWaySelected = false;
@@ -320,5 +322,5 @@
 					}
 				}
-				if (wholeWaySelected)
+				if (someSelectableSegment && wholeWaySelected)
 					selection.add(w);
 			}
Index: /src/org/openstreetmap/josm/gui/layer/GeoImageLayer.java
===================================================================
--- /src/org/openstreetmap/josm/gui/layer/GeoImageLayer.java	(revision 144)
+++ /src/org/openstreetmap/josm/gui/layer/GeoImageLayer.java	(revision 145)
@@ -32,4 +32,5 @@
 import javax.swing.Icon;
 import javax.swing.ImageIcon;
+import javax.swing.JDialog;
 import javax.swing.JFileChooser;
 import javax.swing.JLabel;
@@ -235,5 +236,4 @@
 		final JPanel p = new JPanel(new BorderLayout());
 		final JScrollPane scroll = new JScrollPane(new JLabel(loadScaledImage(e.image, 580)));
-		//scroll.setPreferredSize(new Dimension(800,600));
 		final JViewport vp = scroll.getViewport();
 		p.add(scroll, BorderLayout.CENTER);
@@ -254,5 +254,8 @@
 		});
 		scale.setSelected(true);
-		JOptionPane.showMessageDialog(Main.parent, p, e.image+" ("+e.coor.lat()+","+e.coor.lon()+")", JOptionPane.PLAIN_MESSAGE);
+		JOptionPane pane = new JOptionPane(p, JOptionPane.PLAIN_MESSAGE);
+		JDialog dlg = pane.createDialog(Main.parent, e.image+" ("+e.coor.lat()+","+e.coor.lon()+")");
+		dlg.setModal(false);
+		dlg.setVisible(true);
 	}
 
Index: /src/org/openstreetmap/josm/io/GpxWriter.java
===================================================================
--- /src/org/openstreetmap/josm/io/GpxWriter.java	(revision 144)
+++ /src/org/openstreetmap/josm/io/GpxWriter.java	(revision 145)
@@ -92,5 +92,5 @@
 			GpxWriter writer = new GpxWriter(out);
 			// calculate bounds
-			Bounds b = new Bounds(new LatLon(Double.MAX_VALUE, Double.MAX_VALUE), new LatLon(Double.MIN_VALUE, Double.MIN_VALUE));
+			Bounds b = new Bounds(new LatLon(Double.MAX_VALUE, Double.MAX_VALUE), new LatLon(-Double.MAX_VALUE, -Double.MAX_VALUE));
 			for (Node n : data.nodes)
 				if (!n.deleted)
Index: /src/org/openstreetmap/josm/plugins/Plugin.java
===================================================================
--- /src/org/openstreetmap/josm/plugins/Plugin.java	(revision 144)
+++ /src/org/openstreetmap/josm/plugins/Plugin.java	(revision 145)
@@ -29,4 +29,4 @@
 	 * Called after Main.mapFrame is initalized. (After the first data is loaded).
 	 */
-	public void mapFrameInitialized(MapFrame mapFrame) {}
+	public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {}
 }
Index: /src/org/openstreetmap/josm/plugins/mappaint/MapPaintPlugin.java
===================================================================
--- /src/org/openstreetmap/josm/plugins/mappaint/MapPaintPlugin.java	(revision 144)
+++ /src/org/openstreetmap/josm/plugins/mappaint/MapPaintPlugin.java	(revision 145)
@@ -41,6 +41,9 @@
 	}
 
-	@Override public void mapFrameInitialized(MapFrame mapFrame) {
-		mapFrame.mapView.addLayerChangeListener(this);
+	@Override public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
+		if (newFrame != null)
+			newFrame.mapView.addLayerChangeListener(this);
+		else
+			oldFrame.mapView.removeLayerChangeListener(this);
 	}
 
