Index: /src/org/openstreetmap/josm/Main.java
===================================================================
--- /src/org/openstreetmap/josm/Main.java	(revision 39)
+++ /src/org/openstreetmap/josm/Main.java	(revision 40)
@@ -15,7 +15,7 @@
 
 import org.openstreetmap.josm.actions.AboutAction;
+import org.openstreetmap.josm.actions.DownloadAction;
 import org.openstreetmap.josm.actions.ExitAction;
 import org.openstreetmap.josm.actions.OpenAction;
-import org.openstreetmap.josm.actions.DownloadAction;
 import org.openstreetmap.josm.actions.PreferencesAction;
 import org.openstreetmap.josm.actions.RedoAction;
@@ -26,4 +26,5 @@
 import org.openstreetmap.josm.data.Preferences.PreferencesException;
 import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.gui.BugReportExceptionHandler;
 import org.openstreetmap.josm.gui.ImageProvider;
 import org.openstreetmap.josm.gui.MapFrame;
@@ -144,4 +145,5 @@
 	 */
 	public static void main(String[] args) {
+		setupExceptionHandler();
 		setupUiDefaults();
 		
@@ -217,3 +219,11 @@
 		UIManager.put("OptionPane.noIcon", UIManager.get("OptionPane.cancelIcon"));
 	}
+
+	/**
+	 * Setup an exception handler that displays a sorry message and the possibility
+	 * to do a bug report.
+	 */
+	private static void setupExceptionHandler() {
+		Thread.setDefaultUncaughtExceptionHandler(new BugReportExceptionHandler());
+	}
 }
Index: /src/org/openstreetmap/josm/actions/DownloadAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/DownloadAction.java	(revision 39)
+++ /src/org/openstreetmap/josm/actions/DownloadAction.java	(revision 40)
@@ -77,4 +77,8 @@
 			GeoPoint bottomLeft = mv.getPoint(0, h, true);
 			GeoPoint topRight = mv.getPoint(w, 0, true);
+			if (bottomLeft.isOutSideWorld())
+				bottomLeft = new GeoPoint(-89.999, -179.999); // do not use the Projection constants, since this look better.
+			if (topRight.isOutSideWorld())
+				topRight = new GeoPoint(89.999, 179.999);
 			latlon[0].setText(""+bottomLeft.lat);
 			latlon[1].setText(""+bottomLeft.lon);
Index: /src/org/openstreetmap/josm/actions/OpenAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/OpenAction.java	(revision 39)
+++ /src/org/openstreetmap/josm/actions/OpenAction.java	(revision 40)
@@ -1,5 +1,4 @@
 package org.openstreetmap.josm.actions;
 
-import java.awt.GridBagLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.InputEvent;
@@ -8,14 +7,9 @@
 import java.io.FileReader;
 import java.io.IOException;
-import java.io.Reader;
 import java.util.Collection;
 import java.util.LinkedList;
 
-import javax.swing.Box;
-import javax.swing.JCheckBox;
 import javax.swing.JFileChooser;
-import javax.swing.JLabel;
 import javax.swing.JOptionPane;
-import javax.swing.JPanel;
 import javax.swing.KeyStroke;
 
@@ -24,5 +18,4 @@
 import org.openstreetmap.josm.data.GeoPoint;
 import org.openstreetmap.josm.data.osm.DataSet;
-import org.openstreetmap.josm.gui.GBC;
 import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.layer.Layer;
@@ -55,14 +48,4 @@
 		fc.setAcceptAllFileFilterUsed(true);
 		
-		// additional options
-		JCheckBox rawGps = new JCheckBox("Raw GPS data", true);
-		rawGps.setToolTipText("Check this, if the data were obtained from a gps device.");
-		
-		JPanel p = new JPanel(new GridBagLayout());
-		p.add(new JLabel("Options"), GBC.eop());
-		p.add(rawGps, GBC.eol());
-		p.add(Box.createVerticalGlue(), GBC.eol().fill());
-		fc.setAccessory(p);
-
 		if (fc.showOpenDialog(Main.main) != JFileChooser.APPROVE_OPTION)
 			return;
@@ -74,27 +57,22 @@
 		try {
 			Layer layer;
-			Reader in = new FileReader(filename);
 			String extension = filename.getName().toLowerCase().substring(filename.getName().lastIndexOf('.')+1);
-			if (rawGps.isSelected()) {
+
+			if (asRawData(extension)) {
 				Collection<Collection<GeoPoint>> data;
-				if (extension.equals("gpx"))
-					data = new RawGpsReader(in).parse();
-				else if (extension.equals("xml") || extension.equals("osm")) {
-					JOptionPane.showMessageDialog(Main.main, "Osm server data import for GPS data is not supported.");
-					return;
+				if (extension.equals("gpx")) {
+					data = new RawGpsReader(new FileReader(filename)).parse();
 				} else if (extension.equals("csv") || extension.equals("txt")) {
 					data = new LinkedList<Collection<GeoPoint>>();
-					data.add(new RawCsvReader(in).parse());
-				} else {
-					JOptionPane.showMessageDialog(Main.main, "Unknown file extension: "+extension);
-					return;
-				}
+					data.add(new RawCsvReader(new FileReader(filename)).parse());
+				} else
+					throw new IllegalStateException();
 				layer = new RawGpsDataLayer(data, filename.getName());
 			} else {
 				DataSet dataSet;
 				if (extension.equals("gpx"))
-					dataSet = new GpxReader(in).parse();
+					dataSet = new GpxReader(new FileReader(filename)).parse();
 				else if (extension.equals("xml") || extension.equals("osm"))
-					dataSet = new OsmReader(in).parse();
+					dataSet = new OsmReader(new FileReader(filename)).parse();
 				else if (extension.equals("csv") || extension.equals("txt")) {
 					JOptionPane.showMessageDialog(Main.main, "CSV Data import for non-GPS data is not implemented yet.");
@@ -120,3 +98,17 @@
 		}
 	}
+
+	/**
+	 * @return Return whether the file should be opened as raw gps data. May ask the
+	 * user, if unsure.
+	 */
+	private boolean asRawData(String extension) {
+		if (extension.equals("csv") || extension.equals("txt"))
+			return true;
+		if (!extension.equals("gpx"))
+			return false;
+		return JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(
+				Main.main, "Do you want to open the file as raw gps data?",
+				"Open as raw data?", JOptionPane.YES_NO_OPTION);
+	}
 }
Index: /src/org/openstreetmap/josm/actions/SaveAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/SaveAction.java	(revision 39)
+++ /src/org/openstreetmap/josm/actions/SaveAction.java	(revision 40)
@@ -13,4 +13,5 @@
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.io.GpxWriter;
 import org.openstreetmap.josm.io.OsmWriter;
@@ -37,4 +38,7 @@
 			return;
 		}
+		if (isDataSetEmpty() && JOptionPane.NO_OPTION == JOptionPane.showConfirmDialog(Main.main, "The document contains no data. Save anyway?", "Empty document", JOptionPane.YES_NO_OPTION))
+			return;
+
 		JFileChooser fc = new JFileChooser("data");
 		for (int i = 0; i < ExtensionFileFilter.filters.length; ++i)
@@ -45,12 +49,12 @@
 		if (file == null)
 			return;
-		
+
 		try {
-			FileWriter fileWriter = new FileWriter(file);
 			String fn = file.getName();
+			FileWriter fileWriter;
 			if (fn.endsWith(".gpx"))
-				new GpxWriter(fileWriter).output();
+				new GpxWriter(fileWriter = new FileWriter(file)).output();
 			else if (fn.endsWith(".xml") || fn.endsWith(".osm"))
-				new OsmWriter(fileWriter, Main.main.ds).output();
+				new OsmWriter(fileWriter = new FileWriter(file), Main.main.ds).output();
 			else if (fn.endsWith(".txt") || fn.endsWith(".csv")) {
 				JOptionPane.showMessageDialog(Main.main, "CSV output not supported yet.");
@@ -60,5 +64,4 @@
 				return;
 			}
-				
 			fileWriter.close();
 		} catch (IOException e) {
@@ -68,3 +71,17 @@
 	}
 
+	/**
+	 * Check the data set if it would be empty on save. It is empty, if it contains
+	 * no objects (after all objects that are created and deleted without beeing 
+	 * transfered to the server have been removed).
+	 *  
+	 * @return <code>true</code>, if a save result in an empty data set.
+	 */
+	private boolean isDataSetEmpty() {
+		for (OsmPrimitive osm : Main.main.ds.allPrimitives())
+			if (!osm.isDeleted() || osm.id > 0)
+				return false;
+		return true;
+	}
+
 }
Index: /src/org/openstreetmap/josm/actions/mapmode/AddNodeAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/mapmode/AddNodeAction.java	(revision 39)
+++ /src/org/openstreetmap/josm/actions/mapmode/AddNodeAction.java	(revision 40)
@@ -3,4 +3,6 @@
 import java.awt.event.KeyEvent;
 import java.awt.event.MouseEvent;
+
+import javax.swing.JOptionPane;
 
 import org.openstreetmap.josm.Main;
@@ -50,4 +52,8 @@
 			Node node = new Node();
 			node.coor = mv.getPoint(e.getX(), e.getY(), true);
+			if (node.coor.isOutSideWorld()) {
+				JOptionPane.showMessageDialog(Main.main, "Can not add a node outside of the world.");
+				return;
+			}
 			mv.editLayer().add(new AddCommand(Main.main.ds, node));
 			mv.repaint();
Index: /src/org/openstreetmap/josm/actions/mapmode/MoveAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/mapmode/MoveAction.java	(revision 39)
+++ /src/org/openstreetmap/josm/actions/mapmode/MoveAction.java	(revision 40)
@@ -7,8 +7,11 @@
 import java.util.Collection;
 
+import javax.swing.JOptionPane;
+
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.command.Command;
 import org.openstreetmap.josm.command.MoveCommand;
 import org.openstreetmap.josm.data.GeoPoint;
+import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.gui.MapFrame;
@@ -84,6 +87,16 @@
 
 		Collection<OsmPrimitive> selection = Main.main.ds.getSelected();
+		Collection<Node> affectedNodes = MoveCommand.getAffectedNodes(selection);
+		
+		// check if any coordinate would be outside the world
+		for (OsmPrimitive osm : affectedNodes) {
+			if (osm instanceof Node && ((Node)osm).coor.isOutSideWorld()) {
+				JOptionPane.showMessageDialog(Main.main, "Cannot move objects outside of the world.");
+				return;
+			}
+		}
+		
 		Command c = mv.editLayer().lastCommand();
-		if (c instanceof MoveCommand && MoveCommand.getAffectedNodes(selection).equals(((MoveCommand)c).objects))
+		if (c instanceof MoveCommand && affectedNodes.equals(((MoveCommand)c).objects))
 			((MoveCommand)c).moveAgain(dx,dy);
 		else
Index: /src/org/openstreetmap/josm/command/AddCommand.java
===================================================================
--- /src/org/openstreetmap/josm/command/AddCommand.java	(revision 39)
+++ /src/org/openstreetmap/josm/command/AddCommand.java	(revision 40)
@@ -6,4 +6,5 @@
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.visitor.AddVisitor;
+import org.openstreetmap.josm.data.osm.visitor.DeleteVisitor;
 
 /**
@@ -38,5 +39,5 @@
 
 	public void undoCommand() {
-		osm.setDeleted(true);
+		osm.visit(new DeleteVisitor(ds));
 	}
 
Index: /src/org/openstreetmap/josm/command/DeleteCommand.java
===================================================================
--- /src/org/openstreetmap/josm/command/DeleteCommand.java	(revision 39)
+++ /src/org/openstreetmap/josm/command/DeleteCommand.java	(revision 40)
@@ -6,7 +6,5 @@
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.data.osm.visitor.AddVisitor;
 import org.openstreetmap.josm.data.osm.visitor.CollectBackReferencesVisitor;
-import org.openstreetmap.josm.data.osm.visitor.Visitor;
 
 /**
@@ -39,7 +37,6 @@
 
 	public void undoCommand() {
-		Visitor v = new AddVisitor(ds);
 		for (OsmPrimitive osm : data)
-			osm.visit(v);
+			osm.setDeleted(false);
 	}
 
Index: /src/org/openstreetmap/josm/data/Bounds.java
===================================================================
--- /src/org/openstreetmap/josm/data/Bounds.java	(revision 39)
+++ /src/org/openstreetmap/josm/data/Bounds.java	(revision 40)
@@ -1,3 +1,6 @@
 package org.openstreetmap.josm.data;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.projection.Projection;
 
 /**
@@ -45,5 +48,15 @@
 		this.max = max;
 	}
-	
+
+	/**
+	 * Construct bounds that span the whole world.
+	 */
+	public Bounds() {
+		min = new GeoPoint(-Projection.MAX_LAT, -Projection.MAX_LON);
+		Main.pref.getProjection().latlon2xy(min);
+		max = new GeoPoint(Projection.MAX_LAT, Projection.MAX_LON);
+		Main.pref.getProjection().latlon2xy(max);
+	}
+
 	/**
 	 * @return The bounding rectangle that covers <code>this</code> and 
@@ -59,5 +72,5 @@
 		return new Bounds(nmin, nmax);
 	}
-	
+
 	/**
 	 * @return The bounding rectangle that covers <code>this</code> and 
Index: /src/org/openstreetmap/josm/data/GeoPoint.java
===================================================================
--- /src/org/openstreetmap/josm/data/GeoPoint.java	(revision 39)
+++ /src/org/openstreetmap/josm/data/GeoPoint.java	(revision 40)
@@ -1,3 +1,5 @@
 package org.openstreetmap.josm.data;
+
+import org.openstreetmap.josm.data.projection.Projection;
 
 
@@ -66,3 +68,12 @@
 				!Double.isNaN(lat) && !Double.isNaN(lon);
 	}
+
+	/**
+	 * @return <code>true</code>, if the coordinate is outside the world, compared
+	 * by using lat/lon.
+	 */
+	public boolean isOutSideWorld() {
+		return lat < -Projection.MAX_LAT || lat > Projection.MAX_LAT || 
+			lon < -Projection.MAX_LON || lon > Projection.MAX_LON;
+	}
 }
Index: /src/org/openstreetmap/josm/data/osm/DataSet.java
===================================================================
--- /src/org/openstreetmap/josm/data/osm/DataSet.java	(revision 39)
+++ /src/org/openstreetmap/josm/data/osm/DataSet.java	(revision 40)
@@ -50,4 +50,15 @@
 		o.addAll(lineSegments);
 		o.addAll(tracks);
+		return o;
+	}
+
+	/**
+	 * @return A collection containing all not-deleted primitives (except keys).
+	 */
+	public Collection<OsmPrimitive> allNonDeletedPrimitives() {
+		Collection<OsmPrimitive> o = new LinkedList<OsmPrimitive>();
+		for (OsmPrimitive osm : allPrimitives())
+			if (!osm.isDeleted())
+				o.add(osm);
 		return o;
 	}
Index: /src/org/openstreetmap/josm/data/osm/visitor/AddVisitor.java
===================================================================
--- /src/org/openstreetmap/josm/data/osm/visitor/AddVisitor.java	(revision 39)
+++ /src/org/openstreetmap/josm/data/osm/visitor/AddVisitor.java	(revision 40)
@@ -26,13 +26,10 @@
 	public void visit(Node n) {
 		ds.nodes.add(n);
-		n.setDeleted(false);
 	}
 	public void visit(LineSegment ls) {
 		ds.lineSegments.add(ls);
-		ls.setDeleted(false);
 	}
 	public void visit(Track t) {
 		ds.tracks.add(t);
-		t.setDeleted(false);
 	}
 	public void visit(Key k) {}
Index: /src/org/openstreetmap/josm/data/osm/visitor/CollectBackReferencesVisitor.java
===================================================================
--- /src/org/openstreetmap/josm/data/osm/visitor/CollectBackReferencesVisitor.java	(revision 39)
+++ /src/org/openstreetmap/josm/data/osm/visitor/CollectBackReferencesVisitor.java	(revision 40)
@@ -14,4 +14,7 @@
  * Helper that collect all line segments a node is part of, all tracks
  * a node or line segment is part of and all areas a node is part of. 
+ * 
+ * Deleted objects are not collected.
+ * 
  * @author imi
  */
@@ -25,4 +28,9 @@
 	public final Collection<OsmPrimitive> data = new HashSet<OsmPrimitive>();
 
+
+	/**
+	 * Construct a back reference counter.
+	 * @param ds The dataset to operate on.
+	 */
 	public CollectBackReferencesVisitor(DataSet ds) {
 		this.ds = ds;
@@ -31,4 +39,6 @@
 	public void visit(Node n) {
 		for (Track t : ds.tracks) {
+			if (t.isDeleted())
+				continue;
 			for (LineSegment ls : t.segments) {
 				if (ls.start == n || ls.end == n) {
@@ -38,12 +48,18 @@
 			}
 		}
-		for (LineSegment ls : ds.lineSegments)
+		for (LineSegment ls : ds.lineSegments) {
+			if (ls.isDeleted())
+				continue;
 			if (ls.start == n || ls.end == n)
 				data.add(ls);
+		}
 	}
 	public void visit(LineSegment ls) {
-		for (Track t : ds.tracks)
+		for (Track t : ds.tracks) {
+			if (t.isDeleted())
+				continue;
 			if (t.segments.contains(ls))
 				data.add(t);
+		}
 	}
 	public void visit(Track t) {}
Index: /src/org/openstreetmap/josm/data/osm/visitor/DeleteVisitor.java
===================================================================
--- /src/org/openstreetmap/josm/data/osm/visitor/DeleteVisitor.java	(revision 40)
+++ /src/org/openstreetmap/josm/data/osm/visitor/DeleteVisitor.java	(revision 40)
@@ -0,0 +1,36 @@
+/**
+ */
+package org.openstreetmap.josm.data.osm.visitor;
+
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.osm.Key;
+import org.openstreetmap.josm.data.osm.LineSegment;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.Track;
+
+/**
+ * Visitor, that adds the visited object to the dataset given at constructor.
+ * 
+ * Is not capable of adding keys.
+ * 
+ * @author imi
+ */
+public class DeleteVisitor implements Visitor {
+	
+	private final DataSet ds;
+	
+	public DeleteVisitor(DataSet ds) {
+		this.ds = ds;
+	}
+	
+	public void visit(Node n) {
+		ds.nodes.remove(n);
+	}
+	public void visit(LineSegment ls) {
+		ds.lineSegments.remove(ls);
+	}
+	public void visit(Track t) {
+		ds.tracks.remove(t);
+	}
+	public void visit(Key k) {}
+}
Index: /src/org/openstreetmap/josm/data/projection/Projection.java
===================================================================
--- /src/org/openstreetmap/josm/data/projection/Projection.java	(revision 39)
+++ /src/org/openstreetmap/josm/data/projection/Projection.java	(revision 40)
@@ -18,4 +18,7 @@
  */
 abstract public class Projection implements Cloneable {
+
+	public static double MAX_LAT = 85; // yep - JOSM cannot cartograph the poles.
+	public static double MAX_LON = 179.99999;
 
 	/**
Index: /src/org/openstreetmap/josm/data/projection/UTM.java
===================================================================
--- /src/org/openstreetmap/josm/data/projection/UTM.java	(revision 39)
+++ /src/org/openstreetmap/josm/data/projection/UTM.java	(revision 40)
@@ -195,6 +195,4 @@
 	ZoneData autoDetect(Bounds b) {
 		ZoneData zd = new ZoneData();
-		if (b == null)
-			return zd;
 		GeoPoint center = b.centerLatLon();
 		double lat = center.lat;
Index: /src/org/openstreetmap/josm/gui/BugReportExceptionHandler.java
===================================================================
--- /src/org/openstreetmap/josm/gui/BugReportExceptionHandler.java	(revision 40)
+++ /src/org/openstreetmap/josm/gui/BugReportExceptionHandler.java	(revision 40)
@@ -0,0 +1,79 @@
+package org.openstreetmap.josm.gui;
+
+import java.awt.GridBagLayout;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URL;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+
+import org.openstreetmap.josm.Main;
+
+/**
+ * An exception handler, that ask the user to send a bug report.
+ * 
+ * @author imi
+ */
+public final class BugReportExceptionHandler implements Thread.UncaughtExceptionHandler {
+	public void uncaughtException(Thread t, Throwable e) {
+		if (Main.main == null)
+			e.printStackTrace();
+		else {
+			Object[] options = new String[]{"Do nothing", "Report Bug"};
+			int answer = JOptionPane.showOptionDialog(Main.main, "An unexpected exception occoured.\n\n" +
+					"This is always a coding error. If you are running the latest\n" +
+					"version of JOSM, please consider be kind and file a bug report.",
+					"Unexpected Exception", JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE,
+					null, options, options[0]);
+			if (answer == 1) {
+				try {
+					StringWriter stack = new StringWriter();
+					e.printStackTrace(new PrintWriter(stack));
+
+					URL revUrl = Main.class.getResource("/REVISION");
+					StringBuilder sb = new StringBuilder("Please send this to josm@eigenheimstrasse.de\n\n");
+					if (revUrl == null) {
+						sb.append("Development version. Unknown revision.");
+						File f = new File("org/openstreetmap/josm/Main.class");
+						if (!f.exists())
+							f = new File("bin/org/openstreetmap/josm/Main.class");
+						if (f.exists()) {
+							DateFormat sdf = SimpleDateFormat.getDateTimeInstance();
+							sb.append("\nMain.class build on "+sdf.format(new Date(f.lastModified())));
+							sb.append("\n");
+						}
+					} else {
+						BufferedReader in = new BufferedReader(new InputStreamReader(revUrl.openStream()));
+						for (String line = in.readLine(); line != null; line = in.readLine()) {
+							sb.append(line);
+							sb.append('\n');
+						}
+					}
+					sb.append("\n"+stack.getBuffer().toString());
+
+					JPanel p = new JPanel(new GridBagLayout());
+					p.add(new JLabel("Please send an email with the following information to josm@eigenheimstrasse.de"), GBC.eop());
+
+					JTextArea info = new JTextArea(sb.toString(), 20, 60);
+					info.setCaretPosition(0);
+					info.setEditable(false);
+					p.add(new JScrollPane(info), GBC.eop());
+
+					JOptionPane.showMessageDialog(Main.main, p);
+				} catch (Exception e1) {
+					e1.printStackTrace();
+				}
+			}
+		}
+	}
+}
Index: /src/org/openstreetmap/josm/gui/MapView.java
===================================================================
--- /src/org/openstreetmap/josm/gui/MapView.java	(revision 39)
+++ /src/org/openstreetmap/josm/gui/MapView.java	(revision 40)
@@ -394,4 +394,15 @@
 				l.paint(g, this);
 		}
+		
+		// draw world borders
+		g.setColor(Color.DARK_GRAY);
+		Bounds b = new Bounds();
+		Point min = getScreenPoint(b.min);
+		Point max = getScreenPoint(b.max);
+		int x1 = Math.min(min.x, max.x);
+		int y1 = Math.min(min.y, max.y);
+		int x2 = Math.max(min.x, max.x);
+		int y2 = Math.max(min.y, max.y);
+		g.drawRect(x1, y1, x2-x1+1, y2-y1+1);
 	}
 
Index: /src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
===================================================================
--- /src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java	(revision 39)
+++ /src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java	(revision 40)
@@ -2,4 +2,5 @@
 
 import java.awt.Graphics;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -90,5 +91,7 @@
 	@Override
 	public String getToolTipText() {
-		return data.nodes.size()+" nodes, "+data.lineSegments.size()+" segments, "+data.tracks.size()+" streets.";
+		return undeletedSize(data.nodes)+" nodes, "+
+			undeletedSize(data.lineSegments)+" segments, "+
+			undeletedSize(data.tracks)+" streets.";
 	}
 
@@ -110,5 +113,5 @@
 		for (Node n : data.nodes)
 			b.visit(n);
-		return b.bounds;
+		return b.bounds != null ? b.bounds : new Bounds();
 	}
 
@@ -118,5 +121,5 @@
 		for (Node n : data.nodes)
 			b.visit(n);
-		return b.bounds;
+		return b.bounds != null ? b.bounds : new Bounds();
 	}
 
@@ -197,3 +200,14 @@
 			it.remove();
 	}
+
+	/**
+	 * @return The number of not-deleted primitives in the list.
+	 */
+	private int undeletedSize(Collection<? extends OsmPrimitive> list) {
+		int size = 0;
+		for (OsmPrimitive osm : list)
+			if (!osm.isDeleted())
+				size++;
+		return size;
+	}
 }
Index: /src/org/openstreetmap/josm/io/OsmWriter.java
===================================================================
--- /src/org/openstreetmap/josm/io/OsmWriter.java	(revision 39)
+++ /src/org/openstreetmap/josm/io/OsmWriter.java	(revision 40)
@@ -63,9 +63,7 @@
 		List<Element> list = root.getChildren();
 		properties = new LinkedList<Element>();
-		for (OsmPrimitive osm : ds.allPrimitives()) {
-			if (!osm.isDeleted()) {
-				osm.visit(this);
-				list.add(element);
-			}
+		for (OsmPrimitive osm : ds.allNonDeletedPrimitives()) {
+			osm.visit(this);
+			list.add(element);
 		}
 		list.addAll(properties);
Index: /src/org/openstreetmap/josm/io/RawGpsReader.java
===================================================================
--- /src/org/openstreetmap/josm/io/RawGpsReader.java	(revision 39)
+++ /src/org/openstreetmap/josm/io/RawGpsReader.java	(revision 40)
@@ -55,5 +55,5 @@
 	 */
 	@SuppressWarnings("unchecked")
-	private Collection<Collection<GeoPoint>> parseData(Element root) {
+	private Collection<Collection<GeoPoint>> parseData(Element root) throws JDOMException {
 		Collection<Collection<GeoPoint>> data = new LinkedList<Collection<GeoPoint>>();
 
@@ -63,7 +63,5 @@
 		for (Object o : root.getChildren("wpt", GPX)) {
 			Collection<GeoPoint> line = new LinkedList<GeoPoint>();
-			line.add(new GeoPoint(
-					Float.parseFloat(((Element)o).getAttributeValue("lat")),
-					Float.parseFloat(((Element)o).getAttributeValue("lon"))));
+			line.add(new GeoPoint(parseFloat((Element)o, LatLon.lat), parseFloat((Element)o, LatLon.lon)));
 			data.add(line);
 		}
@@ -83,14 +81,26 @@
 	}
 
+	enum LatLon {lat, lon}
+	/**
+	 * Return a parsed float value from the element behind the object o.
+	 * @param o An object of dynamic type org.jdom.Element (will be casted).
+	 * @param attr The name of the attribute.
+	 * @throws JDOMException If the absolute of the value is out of bound.
+	 */
+	private float parseFloat(Element e, LatLon attr) throws JDOMException {
+		float f = Float.parseFloat(e.getAttributeValue(attr.toString()));
+		if (Math.abs(f) > (attr == LatLon.lat ? 90 : 180))
+			throw new JDOMException("Data error: "+attr+" value '"+f+"' is out of bound.");
+		return f;
+	}
+
 	/**
 	 * Parse the list of trackpoint - elements and return a collection with the
 	 * points read.
 	 */
-	private Collection<GeoPoint> parseLine(List<Element> wpt) {
+	private Collection<GeoPoint> parseLine(List<Element> wpt) throws JDOMException {
 		Collection<GeoPoint> data = new LinkedList<GeoPoint>();
 		for (Element e : wpt)
-			data.add(new GeoPoint(
-					Float.parseFloat(e.getAttributeValue("lat")),
-					Float.parseFloat(e.getAttributeValue("lon"))));
+			data.add(new GeoPoint(parseFloat(e, LatLon.lat), parseFloat(e, LatLon.lon)));
 		return data;
 	}
