Index: /src/org/openstreetmap/josm/Main.java
===================================================================
--- /src/org/openstreetmap/josm/Main.java	(revision 29)
+++ /src/org/openstreetmap/josm/Main.java	(revision 30)
@@ -20,5 +20,4 @@
 import org.openstreetmap.josm.actions.PreferencesAction;
 import org.openstreetmap.josm.actions.SaveAction;
-import org.openstreetmap.josm.actions.SaveGpxAction;
 import org.openstreetmap.josm.actions.UndoAction;
 import org.openstreetmap.josm.data.Preferences;
@@ -79,5 +78,4 @@
 		OpenAction openAction = new OpenAction();
 		SaveAction saveAction = new SaveAction();
-		SaveGpxAction saveGpxAction = new SaveGpxAction();
 		ExitAction exitAction = new ExitAction();
 		UndoAction undoAction = new UndoAction();
@@ -93,5 +91,4 @@
 		fileMenu.add(openAction);
 		fileMenu.add(saveAction);
-		fileMenu.add(saveGpxAction);
 		fileMenu.addSeparator();
 		fileMenu.add(exitAction);
@@ -106,5 +103,5 @@
 		JMenu editMenu = new JMenu("Edit");
 		editMenu.setMnemonic('E');
-		//editMenu.add(undoAction);
+		editMenu.add(undoAction);
 		editMenu.addSeparator();
 		editMenu.add(preferencesAction);
@@ -123,7 +120,6 @@
 		toolBar.add(openAction);
 		toolBar.add(saveAction);
-		toolBar.add(saveGpxAction);
 		toolBar.addSeparator();
-		//toolBar.add(undoAction);
+		toolBar.add(undoAction);
 		toolBar.addSeparator();
 		toolBar.add(preferencesAction);
Index: /src/org/openstreetmap/josm/actions/AboutAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/AboutAction.java	(revision 29)
+++ /src/org/openstreetmap/josm/actions/AboutAction.java	(revision 30)
@@ -13,5 +13,4 @@
 import java.util.regex.Pattern;
 
-import javax.swing.AbstractAction;
 import javax.swing.JEditorPane;
 import javax.swing.JLabel;
@@ -36,10 +35,8 @@
  * @author imi
  */
-public class AboutAction extends AbstractAction {
+public class AboutAction extends JosmAction {
 	
 	public AboutAction() {
-		super("About", ImageProvider.get("about"));
-		putValue(MNEMONIC_KEY, KeyEvent.VK_A);
-		putValue(SHORT_DESCRIPTION, "Display the about screen.");
+		super("About", "about", "Display the about screen.", KeyEvent.VK_A, null);
 	}
 	
Index: /src/org/openstreetmap/josm/actions/AutoScaleAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/AutoScaleAction.java	(revision 29)
+++ /src/org/openstreetmap/josm/actions/AutoScaleAction.java	(revision 30)
@@ -4,9 +4,4 @@
 import java.awt.event.KeyEvent;
 
-import javax.swing.AbstractAction;
-import javax.swing.JComponent;
-import javax.swing.KeyStroke;
-
-import org.openstreetmap.josm.gui.ImageProvider;
 import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.MapView;
@@ -16,5 +11,5 @@
  * @author imi
  */
-public class AutoScaleAction extends AbstractAction {
+public class AutoScaleAction extends JosmAction {
 	/**
 	 * The mapView this action operates on.
@@ -23,12 +18,7 @@
 	
 	public AutoScaleAction(MapFrame mapFrame) {
-		super("Auto Scale", ImageProvider.get("autoscale"));
+		super("Auto Scale", "autoscale", "Zoom the view to show the whole layer. Disabled if the view is moved.",
+				KeyEvent.VK_A, null);
 		mapView = mapFrame.mapView;
-		putValue(MNEMONIC_KEY, KeyEvent.VK_A);
-		putValue(SHORT_DESCRIPTION, "Zoom the view to show the whole layer. Disabled if the view is moved.");
-		KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_A, 0);
-		putValue(ACCELERATOR_KEY, ks);
-		mapFrame.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ks, this);
-		mapFrame.getActionMap().put(this, this);
 	}
 
Index: /src/org/openstreetmap/josm/actions/ExitAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/ExitAction.java	(revision 29)
+++ /src/org/openstreetmap/josm/actions/ExitAction.java	(revision 30)
@@ -3,8 +3,4 @@
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
-
-import javax.swing.AbstractAction;
-
-import org.openstreetmap.josm.gui.ImageProvider;
 
 /**
@@ -13,5 +9,5 @@
  * @author imi
  */
-public class ExitAction extends AbstractAction {
+public class ExitAction extends JosmAction {
 
 	/**
@@ -19,7 +15,5 @@
 	 */
 	public ExitAction() {
-		super("Exit", ImageProvider.get("exit"));
-		putValue(MNEMONIC_KEY, KeyEvent.VK_X);
-		putValue(SHORT_DESCRIPTION, "Exit the application.");
+		super("Exit", "exit", "Exit the application.", KeyEvent.VK_X, null);
 	}
 	
Index: /src/org/openstreetmap/josm/actions/JosmAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/JosmAction.java	(revision 30)
+++ /src/org/openstreetmap/josm/actions/JosmAction.java	(revision 30)
@@ -0,0 +1,32 @@
+package org.openstreetmap.josm.actions;
+
+import java.awt.AWTKeyStroke;
+
+import javax.swing.AbstractAction;
+
+import org.openstreetmap.josm.gui.ImageProvider;
+
+/**
+ * Base class helper for all Actions in JOSM. Just to make the life easier.
+ * @author imi
+ */
+abstract public class JosmAction extends AbstractAction {
+
+	/**
+	 * Construct the action.
+	 * 
+	 * @param name		Name of the action (entry name in menu)
+	 * @param iconName	Name of the icon (without extension)
+	 * @param desc		Short tooltip description
+	 * @param mnemonic	If non-<code>null</code>, the Mnemonic in menu
+	 * @param shortCut	If non-<code>null</code>, the shortcut keystroke
+	 */
+	public JosmAction(String name, String iconName, String desc, Integer mnemonic, AWTKeyStroke shortCut) {
+		super(name, ImageProvider.get(iconName));
+		putValue(SHORT_DESCRIPTION, desc);
+		if (mnemonic != null)
+			putValue(MNEMONIC_KEY, mnemonic);
+		if (shortCut != null)
+			putValue(ACCELERATOR_KEY, shortCut);
+	}
+}
Index: /src/org/openstreetmap/josm/actions/OpenAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/OpenAction.java	(revision 29)
+++ /src/org/openstreetmap/josm/actions/OpenAction.java	(revision 30)
@@ -10,5 +10,4 @@
 import java.util.Collection;
 
-import javax.swing.AbstractAction;
 import javax.swing.Box;
 import javax.swing.JCheckBox;
@@ -24,7 +23,5 @@
 import org.openstreetmap.josm.data.GeoPoint;
 import org.openstreetmap.josm.data.osm.DataSet;
-import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.gui.GBC;
-import org.openstreetmap.josm.gui.ImageProvider;
 import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.layer.Layer;
@@ -41,5 +38,5 @@
  * @author imi
  */
-public class OpenAction extends AbstractAction {
+public class OpenAction extends JosmAction {
 
 	/**
@@ -47,8 +44,5 @@
 	 */
 	public OpenAction() {
-		super("Open", ImageProvider.get("open"));
-		putValue(ACCELERATOR_KEY, KeyStroke.getAWTKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK));
-		putValue(MNEMONIC_KEY, KeyEvent.VK_O);
-		putValue(SHORT_DESCRIPTION, "Open a file.");
+		super("Open", "open", "Open a file.", null, KeyStroke.getAWTKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK));
 	}
 
@@ -96,9 +90,8 @@
 				layer = new RawGpsDataLayer(data, filename.getName());
 			} else {
-				DataSet dataSet = filename.getName().toLowerCase().endsWith("gpx") ?
+				DataSet dataSet = filename.getName().toLowerCase().endsWith(".gpx") ?
 						new GpxReader(new FileReader(filename)).parse() :
 						new OsmReader(new FileReader(filename)).parse();
-				Collection<OsmPrimitive> l = Main.main.ds.mergeFrom(dataSet);
-				layer = new OsmDataLayer(l, filename.getName());
+				layer = new OsmDataLayer(dataSet, filename.getName());
 			}
 			
Index: /src/org/openstreetmap/josm/actions/OpenOsmServerAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/OpenOsmServerAction.java	(revision 29)
+++ /src/org/openstreetmap/josm/actions/OpenOsmServerAction.java	(revision 30)
@@ -5,9 +5,8 @@
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.InputEvent;
 import java.awt.event.KeyEvent;
 import java.io.IOException;
-import java.util.Collection;
 
-import javax.swing.AbstractAction;
 import javax.swing.DefaultListModel;
 import javax.swing.JButton;
@@ -18,4 +17,5 @@
 import javax.swing.JScrollPane;
 import javax.swing.JTextField;
+import javax.swing.KeyStroke;
 import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
@@ -25,8 +25,6 @@
 import org.openstreetmap.josm.data.GeoPoint;
 import org.openstreetmap.josm.data.osm.DataSet;
-import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.gui.BookmarkList;
 import org.openstreetmap.josm.gui.GBC;
-import org.openstreetmap.josm.gui.ImageProvider;
 import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.MapView;
@@ -45,5 +43,5 @@
  * @author imi
  */
-public class OpenOsmServerAction extends AbstractAction {
+public class OpenOsmServerAction extends JosmAction {
 
 	JTextField[] latlon = new JTextField[]{
@@ -55,7 +53,6 @@
 
 	public OpenOsmServerAction() {
-		super("Connect to OSM", ImageProvider.get("connectosm"));
-		putValue(MNEMONIC_KEY, KeyEvent.VK_C);
-		putValue(SHORT_DESCRIPTION, "Open a connection to the OSM server.");
+		super("Connect to OSM", "connectosm", "Open a connection to the OSM server.", KeyEvent.VK_C, 
+				KeyStroke.getAWTKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
 	}
 
@@ -163,6 +160,5 @@
 					JOptionPane.showMessageDialog(Main.main, "No data imported.");
 				
-				Collection<OsmPrimitive> data = Main.main.ds.mergeFrom(dataSet);
-				layer = new OsmDataLayer(data, name);
+				layer = new OsmDataLayer(dataSet, name);
 			}
 
Index: /src/org/openstreetmap/josm/actions/PreferencesAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/PreferencesAction.java	(revision 29)
+++ /src/org/openstreetmap/josm/actions/PreferencesAction.java	(revision 30)
@@ -2,11 +2,6 @@
 
 import java.awt.event.ActionEvent;
-import java.awt.event.InputEvent;
 import java.awt.event.KeyEvent;
 
-import javax.swing.AbstractAction;
-import javax.swing.KeyStroke;
-
-import org.openstreetmap.josm.gui.ImageProvider;
 import org.openstreetmap.josm.gui.PreferenceDialog;
 
@@ -16,5 +11,5 @@
  * @author imi
  */
-public class PreferencesAction extends AbstractAction {
+public class PreferencesAction extends JosmAction {
 
 	/**
@@ -22,8 +17,6 @@
 	 */
 	public PreferencesAction() {
-		super("Preferences", ImageProvider.get("preference"));
-		putValue(ACCELERATOR_KEY, KeyStroke.getAWTKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_DOWN_MASK));
-		putValue(MNEMONIC_KEY, KeyEvent.VK_P);
-		putValue(SHORT_DESCRIPTION, "Open a preferences page for global settings.");
+		super("Preferences", "preference", "Open a preferences page for global settings.",
+				KeyEvent.VK_P, null);
 	}
 
Index: /src/org/openstreetmap/josm/actions/SaveAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/SaveAction.java	(revision 29)
+++ /src/org/openstreetmap/josm/actions/SaveAction.java	(revision 30)
@@ -8,5 +8,4 @@
 import java.io.IOException;
 
-import javax.swing.AbstractAction;
 import javax.swing.JFileChooser;
 import javax.swing.JOptionPane;
@@ -15,5 +14,5 @@
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.gui.ImageProvider;
+import org.openstreetmap.josm.io.GpxWriter;
 import org.openstreetmap.josm.io.OsmWriter;
 
@@ -25,5 +24,5 @@
  * @author imi
  */
-public class SaveAction extends AbstractAction {
+public class SaveAction extends JosmAction {
 
 	/**
@@ -31,7 +30,5 @@
 	 */
 	public SaveAction() {
-		super("Save", ImageProvider.get("save"));
-		putValue(ACCELERATOR_KEY, KeyStroke.getAWTKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));
-		putValue(SHORT_DESCRIPTION, "Save the current data.");
+		super("Save", "save", "Save the current data.", null, KeyStroke.getAWTKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));
 	}
 	
@@ -46,9 +43,9 @@
 			public boolean accept(File f) {
 				String name = f.getName().toLowerCase();
-				return f.isDirectory() || name.endsWith(".xml");
+				return f.isDirectory() || name.endsWith(".xml") || name.endsWith(".gpx");
 			}
 			@Override
 			public String getDescription() {
-				return "XML Files";
+				return "GPX or XML Files";
 			}
 		});
@@ -60,6 +57,8 @@
 		try {
 			FileWriter fileWriter = new FileWriter(file);
-			OsmWriter out = new OsmWriter(fileWriter, Main.main.ds);
-			out.output();
+			if (file.getName().endsWith(".gpx"))
+				new GpxWriter(fileWriter).output();
+			else
+				new OsmWriter(fileWriter, Main.main.ds).output();
 			fileWriter.close();
 		} catch (IOException e) {
Index: c/org/openstreetmap/josm/actions/SaveGpxAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/SaveGpxAction.java	(revision 29)
+++ 	(revision )
@@ -1,61 +1,0 @@
-package org.openstreetmap.josm.actions;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-
-import javax.swing.AbstractAction;
-import javax.swing.JFileChooser;
-import javax.swing.JOptionPane;
-import javax.swing.KeyStroke;
-
-import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.gui.ImageProvider;
-import org.openstreetmap.josm.io.GpxWriter;
-
-/**
- * Export the current selected window's DataSet as gpx values. Remember, that some 
- * information could be lost. If so, an information message will ask the user to proceed.
- * (Means, if all information can be saved, no warning message appears).
- *  
- * @author imi
- */
-public class SaveGpxAction extends AbstractAction {
-
-	/**
-	 * Construct the action with "Save GPX" as label.
-	 */
-	public SaveGpxAction() {
-		super("Save GPX", ImageProvider.get("savegpx"));
-		putValue(ACCELERATOR_KEY, KeyStroke.getAWTKeyStroke(KeyEvent.VK_S,
-				InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK));
-		putValue(MNEMONIC_KEY, KeyEvent.VK_S);
-		putValue(SHORT_DESCRIPTION, "Export the current data as GPX file.");
-	}
-	
-	public void actionPerformed(ActionEvent event) {
-		if (Main.main.getMapFrame() == null) {
-			JOptionPane.showMessageDialog(Main.main, "No document open so nothing to save.");
-			return;
-		}
-		JFileChooser fc = new JFileChooser("data");
-		fc.showSaveDialog(Main.main);
-		File gpxFile = fc.getSelectedFile();
-		if (gpxFile == null)
-			return;
-		
-		try {
-			FileWriter fileWriter = new FileWriter(gpxFile);
-			GpxWriter out = new GpxWriter(fileWriter);
-			out.output();
-			fileWriter.close();
-		} catch (IOException e) {
-			e.printStackTrace();
-			JOptionPane.showMessageDialog(Main.main, "An error occoured while saving.\n"+e.getMessage());
-		}
-	}
-
-}
Index: /src/org/openstreetmap/josm/actions/UndoAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/UndoAction.java	(revision 29)
+++ /src/org/openstreetmap/josm/actions/UndoAction.java	(revision 30)
@@ -4,12 +4,8 @@
 import java.awt.event.InputEvent;
 import java.awt.event.KeyEvent;
-import java.util.LinkedList;
 
-import javax.swing.AbstractAction;
 import javax.swing.KeyStroke;
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.command.Command;
-import org.openstreetmap.josm.gui.ImageProvider;
 
 
@@ -19,5 +15,5 @@
  * @author imi
  */
-public class UndoAction extends AbstractAction {
+public class UndoAction extends JosmAction {
 
 	/**
@@ -25,7 +21,5 @@
 	 */
 	public UndoAction() {
-		super("Undo", ImageProvider.get("undo"));
-		putValue(ACCELERATOR_KEY, KeyStroke.getAWTKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK));
-		putValue(SHORT_DESCRIPTION, "Undo the last action.");
+		super("Undo", "undo", "Undo the last action.", null, KeyStroke.getAWTKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK));
 	}
 	
@@ -33,11 +27,6 @@
 		if (Main.main.getMapFrame() == null)
 			return;
-		LinkedList<Command> commands = Main.main.getMapFrame().mapView.editLayer().commands;
-		if (commands.isEmpty())
-			return;
-		Command c = commands.getLast();
-		//c.undoCommand();
-		commands.removeLast();
 		Main.main.getMapFrame().repaint();
+		Main.main.getMapFrame().mapView.editLayer().undo();
 	}
 }
Index: /src/org/openstreetmap/josm/actions/mapmode/AddLineSegmentAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/mapmode/AddLineSegmentAction.java	(revision 29)
+++ /src/org/openstreetmap/josm/actions/mapmode/AddLineSegmentAction.java	(revision 30)
@@ -4,9 +4,8 @@
 import java.awt.Graphics;
 import java.awt.Point;
+import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseListener;
-
-import javax.swing.JOptionPane;
 
 import org.openstreetmap.josm.Main;
@@ -15,5 +14,4 @@
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.data.osm.Track;
 import org.openstreetmap.josm.gui.MapFrame;
 
@@ -22,12 +20,6 @@
  * starting node and dragging to the ending node. 
  * 
- * If the Alt key was pressed when releasing the mouse, this action tries to
- * add the line segment to a track. The new line segment gets added to all tracks
- * of the first node that end in the first node. If no tracks are found, the
- * line segment gets added to all tracks in the second node that start with
- * the second node.
- * 
  * No line segment can be created if there is already a line segment containing
- * both nodes in the same order.
+ * both nodes.
  * 
  * @author imi
@@ -72,4 +64,11 @@
 	}
 
+	
+	@Override
+	public void actionPerformed(ActionEvent e) {
+		super.actionPerformed(e);
+		makeLineSegment();
+	}
+
 	/**
 	 * If user clicked on a node, start the dragging with that node. 
@@ -108,12 +107,19 @@
 
 	/**
+	 * If left button was released, try to create the line segment.
+	 */
+	@Override
+	public void mouseReleased(MouseEvent e) {
+		if (e.getButton() == MouseEvent.BUTTON1) {
+			makeLineSegment();
+			first = null; // release line segment drawing
+		}
+	}
+
+	/**
 	 * Create the line segment if first and second are different and there is
 	 * not already a line segment.
 	 */
-	@Override
-	public void mouseReleased(MouseEvent e) {
-		if (e.getButton() != MouseEvent.BUTTON1)
-			return;
-
+	private void makeLineSegment() {
 		if (first == null || second == null) {
 			first = null;
@@ -126,20 +132,17 @@
 		Node start = first;
 		Node end = second;
-		first = null;
+		first = second;
 		second = null;
 		
 		if (start != end) {
 			// try to find a line segment
-			for (Track t : Main.main.ds.tracks)
-				for (LineSegment ls : t.segments)
-					if (start == ls.start && end == ls.end) {
-						JOptionPane.showMessageDialog(Main.main, "There is already an line segment with the same direction between the selected nodes.");
-						return;
-					}
+			for (LineSegment ls : Main.main.ds.lineSegments)
+				if ((start == ls.start && end == ls.end) || (end == ls.start && start == ls.end))
+					return; // already a line segment here - be happy, do nothing.
 
 			LineSegment ls = new LineSegment(start, end);
-			mv.editLayer().add(new AddCommand(ls));
+			mv.editLayer().add(new AddCommand(Main.main.ds, ls));
 		}
-		
+
 		mv.repaint();
 	}
Index: /src/org/openstreetmap/josm/actions/mapmode/AddNodeAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/mapmode/AddNodeAction.java	(revision 29)
+++ /src/org/openstreetmap/josm/actions/mapmode/AddNodeAction.java	(revision 30)
@@ -4,4 +4,5 @@
 import java.awt.event.MouseEvent;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.command.AddCommand;
 import org.openstreetmap.josm.data.osm.Node;
@@ -49,5 +50,5 @@
 			Node node = new Node();
 			node.coor = mv.getPoint(e.getX(), e.getY(), true);
-			mv.editLayer().add(new AddCommand(node));
+			mv.editLayer().add(new AddCommand(Main.main.ds, node));
 			mv.repaint();
 		}
Index: /src/org/openstreetmap/josm/actions/mapmode/AddTrackAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/mapmode/AddTrackAction.java	(revision 29)
+++ /src/org/openstreetmap/josm/actions/mapmode/AddTrackAction.java	(revision 30)
@@ -2,4 +2,5 @@
 
 import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
 import java.util.Collection;
@@ -61,4 +62,11 @@
 	}
 
+	
+	@Override
+	public void actionPerformed(ActionEvent e) {
+		makeTrack();
+		super.actionPerformed(e);
+	}
+
 	/**
 	 * If Shift is pressed, only add the selected line segments to the selection.
@@ -90,4 +98,11 @@
 			return; // no new track yet.
 		
+		makeTrack();
+	}
+
+	/**
+	 * Just make a track of all selected items.
+	 */
+	private void makeTrack() {
 		Collection<OsmPrimitive> selection = Main.main.ds.getSelected();
 		if (selection.isEmpty())
@@ -135,6 +150,7 @@
 		for (LineSegment ls : sortedLineSegments)
 			t.add(ls);
-		mv.editLayer().add(new AddCommand(t));
+		mv.editLayer().add(new AddCommand(Main.main.ds, t));
 		Main.main.ds.clearSelection();
+		mv.repaint();
 	}
 }
Index: c/org/openstreetmap/josm/actions/mapmode/CombineAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/mapmode/CombineAction.java	(revision 29)
+++ 	(revision )
@@ -1,197 +1,0 @@
-package org.openstreetmap.josm.actions.mapmode;
-
-import java.awt.Color;
-import java.awt.Graphics;
-import java.awt.Point;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseEvent;
-
-import javax.swing.JOptionPane;
-
-import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.command.CombineCommand;
-import org.openstreetmap.josm.data.osm.LineSegment;
-import org.openstreetmap.josm.data.osm.Node;
-import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.data.osm.Track;
-import org.openstreetmap.josm.gui.MapFrame;
-
-/**
- * A MapMode that allows the user to combine two objects to a new one.
- * 
- * When entering CombineAction, all selection is cleared.
- * 
- * The user can select objects by dragging them to another object, so the object 
- * he pressed and the one he released the button are combined. No selection 
- * rectangle is supported. 
- * 
- * Even if the user don't press Alt, tracks instead of line segments are selected. 
- * This means, it is impossible to select non-pending line segments.
- * 
- * Pressing Ctrl or Shift has no effect too.
- *
- * No object can be combined with an object it is already part of. E.g. line
- * segment cannot be combined with a track it is part of. In case of such a 
- * constillation, the user is informed.
- *
- * When combining, the object the user pressed on is called <i>source</i> and 
- * the object the button was released on is called <i>target</i>.
- *
- * The following objects can be combined:
- *
- * - A line segment and a track can be combined if one of them is a pending line
- *   segment. This get integrated into the track.
- * - Two tracks can be combined. The latter track get removed and all its 
- *   segments are moved to the first track. This is only possible, if both 
- *   tracks have no different value in any key.
- * - Two areas can be combined, if they share at least one node, in which case
- *   the combined area span both areas. If the areas share more than one node,
- *   all lines between the areas get removed. This is only possible if both areas
- *   have no different value in any key.
- *
- * All other object combinations cannot be combined.
- * 
- * TODO: This and AddLineSegmentAction are similar. Refactor both.
- * 
- * @author imi
- */
-public class CombineAction extends MapMode {
-
-	/**
-	 * The object that was first selected as combine source. 
-	 */
-	private OsmPrimitive first;
-	/**
-	 * The object that was last selected as combine target. 
-	 */
-	private OsmPrimitive second;
-	/**
-	 * Whether a hint is drawn on screen or not.
-	 */
-	private boolean combineHintDrawn = false;
-
-	/**
-	 * Constructs a CombineAction. Mnemonic is "c".
-	 */
-	public CombineAction(MapFrame mapFrame) {
-		super("Combine", "combine", "Combine objects together.", KeyEvent.VK_C, mapFrame);
-	}
-
-	@Override
-	public void registerListener() {
-		super.registerListener();
-		mv.addMouseListener(this);
-		mv.addMouseMotionListener(this);
-		Main.main.ds.clearSelection();
-	}
-
-	@Override
-	public void unregisterListener() {
-		super.unregisterListener();
-		mv.removeMouseListener(this);
-		mv.removeMouseMotionListener(this);
-		drawCombineHint(false);
-	}
-
-	/**
-	 * If nothing is selected, select the object nearest to the mouse. Else
-	 * start the "display possible combining" phase and draw a hint what would
-	 * be combined if user releases the button. 
-	 */
-	@Override
-	public void mousePressed(MouseEvent e) {
-		if (e.getButton() != MouseEvent.BUTTON1)
-			return;
-
-		OsmPrimitive clicked = mv.getNearest(e.getPoint(), true);
-		if (clicked == null || clicked instanceof Node)
-			return;
-
-		drawCombineHint(false);
-		first = second = clicked;
-	}
-
-	/**
-	 * Updates the drawn combine hint if necessary.
-	 */
-	@Override
-	public void mouseDragged(MouseEvent e) {
-		if ((e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) == 0)
-			return;
-		
-		OsmPrimitive clicked = mv.getNearest(e.getPoint(), true);
-		if (clicked == null || clicked == second || clicked instanceof Node)
-			return;
-
-		drawCombineHint(false);
-		second = clicked;
-		drawCombineHint(true);
-	}
-	
-	/**
-	 * Start combining (if there is something to combine).
-	 */
-	@Override
-	public void mouseReleased(MouseEvent e) {
-		if (e.getButton() != MouseEvent.BUTTON1)
-			return;
-
-		if (first == null || second == null || first == second) {
-			first = null;
-			second = null;
-			return;
-		}
-
-		drawCombineHint(false);
-		
-		if (first instanceof LineSegment && second instanceof LineSegment)
-			JOptionPane.showMessageDialog(Main.main, "Cannot combine two line segments. To create tracks use 'Add Track'.");
-		else if (first instanceof Track && second instanceof Track && !first.keyPropertiesMergable(second))
-			JOptionPane.showMessageDialog(Main.main, "Cannot combine because of different properties.");
-		else
-			mv.editLayer().add(new CombineCommand(first, second));
-		mv.repaint();
-	}
-
-	/**
-	 * Draws or removes the combine hint using the combineHint structure.
-	 *
-	 * @param draw 	<code>true</code> to draw the hint or 
-	 * 				<code>false</code> to remove it.
-	 */
-	private void drawCombineHint(boolean draw) {
-		if (draw == combineHintDrawn)
-			return;
-		if (first == null || second == null)
-			return;
-		if (second == first)
-			return;
-
-		Graphics g = mv.getGraphics();
-		g.setColor(Color.BLACK);
-		g.setXORMode(Color.WHITE);
-		draw(g, first);
-		draw(g, second);
-		combineHintDrawn = !combineHintDrawn;
-	}
-
-	/**
-	 * Draw a hint for the specified primitive
-	 * @param g The graphic to draw into
-	 * @param osm The primitive to draw a hint for.
-	 */
-	private void draw(Graphics g, OsmPrimitive osm) {
-		if (osm instanceof LineSegment) {
-			LineSegment ls = (LineSegment)osm;
-			Point start = mv.getScreenPoint(ls.start.coor);
-			Point end = mv.getScreenPoint(ls.end.coor);
-			if (Main.main.ds.pendingLineSegments.contains(osm) && g.getColor() == Color.GRAY)
-				g.drawLine(start.x, start.y, end.x, end.y);
-			else
-				g.drawLine(start.x, start.y, end.x, end.y);
-		} else if (osm instanceof Track) {
-			for (LineSegment ls : ((Track)osm).segments)
-				draw(g, ls);
-		}
-	}
-}
Index: /src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java	(revision 29)
+++ /src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java	(revision 30)
@@ -1,8 +1,11 @@
 package org.openstreetmap.josm.actions.mapmode;
 
+import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
 import java.awt.event.MouseEvent;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
 import java.util.LinkedList;
 
@@ -12,5 +15,5 @@
 import org.openstreetmap.josm.command.CombineAndDeleteCommand;
 import org.openstreetmap.josm.command.DeleteCommand;
-import org.openstreetmap.josm.command.CombineAndDeleteCommand.LineSegmentCombineEntry;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.LineSegment;
 import org.openstreetmap.josm.data.osm.Node;
@@ -32,14 +35,7 @@
  * tries to combine the referencing objects as follows:
  *
- * If a node is part of exactly two line segments from a track, the two line 
- * segments are combined into one. The first line segment spans now to the end 
- * of the second and the second line segment gets deleted. This is checked for
- * every track.
- * 
- * If a node is the end of the ending line segment of one track and the start of
- * exactly one other tracks start segment, the tracks are combined into one track,
- * deleting the second track and keeping the first one. The ending line segment 
- * of the fist track is combined with the starting line segment of the second 
- * track.
+ * If a node is part of exactly two line segments, the two line segments are 
+ * combined into one. The first line segment spans now to the end of the 
+ * second and the second line segment gets deleted.
  * 
  * Combining is only possible, if both objects that should be combined have no
@@ -55,5 +51,5 @@
  * 
  * If the user enters the mapmode and any object is selected, all selected
- * objects get deleted. Combining applies to the selected objects.
+ * objects that can be deleted will. Combining applies to the selected objects.
  * 
  * @author imi
@@ -66,5 +62,5 @@
 	 */
 	public DeleteAction(MapFrame mapFrame) {
-		super("Delete", "delete", "Delete nodes, streets or areas.", KeyEvent.VK_DELETE, mapFrame);
+		super("Delete", "delete", "Delete nodes, streets or areas.", KeyEvent.VK_D, mapFrame);
 	}
 
@@ -81,4 +77,30 @@
 	}
 
+	
+	@Override
+	public void actionPerformed(ActionEvent e) {
+		super.actionPerformed(e);
+		boolean ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0;
+		Collection<OsmPrimitive> selection = Main.main.ds.getSelected();
+		
+		int selSize = 0;
+		// loop as long as the selection size changes
+		while(selSize != selection.size()) {
+			selSize = selection.size();
+
+			for (Iterator<OsmPrimitive> it = selection.iterator(); it.hasNext();) {
+				OsmPrimitive osm = it.next();
+				if (ctrl) {
+					deleteWithReferences(osm);
+					it.remove();
+				} else {
+					if (delete(osm, false))
+						it.remove();
+				}
+			}
+		}
+		mv.repaint();
+	}
+
 	/**
 	 * If user clicked with the left button, delete the nearest object.
@@ -97,5 +119,5 @@
 			deleteWithReferences(sel);
 		else
-			delete(sel);
+			delete(sel, true);
 
 		mv.repaint();
@@ -124,9 +146,9 @@
 	 * TODO If you delete x, then a,B,C and x gets deleted. A now consist of b only.
 	 * If you delete a or b, then A, a, b and z gets deleted.
-	 *
+	 * 
 	 * @param osm The object to delete.
 	 */
 	private void deleteWithReferences(OsmPrimitive osm) {
-		// collect all tracks, areas and pending line segments that should be deleted
+		// collect all tracks, areas and line segments that should be deleted
 		ArrayList<Track> tracksToDelete = new ArrayList<Track>();
 		ArrayList<LineSegment> lineSegmentsToDelete = new ArrayList<LineSegment>();
@@ -138,5 +160,5 @@
 					if (ls.start == osm || ls.end == osm)
 						tracksToDelete.add(t);
-			for (LineSegment ls : Main.main.ds.pendingLineSegments)
+			for (LineSegment ls : Main.main.ds.lineSegments)
 				if (ls.start == osm || ls.end == osm)
 					lineSegmentsToDelete.add(ls);
@@ -164,5 +186,5 @@
 			checkUnreferencing.add(ls.end);
 		}
-		
+
 		Collection<OsmPrimitive> deleteData = new LinkedList<OsmPrimitive>();
 		deleteData.addAll(tracksToDelete);
@@ -175,6 +197,6 @@
 		if (osm instanceof Node)
 			deleteData.add(osm);
-		
-		mv.editLayer().add(new DeleteCommand(deleteData));
+
+		mv.editLayer().add(new DeleteCommand(Main.main.ds, deleteData));
 	}
 
@@ -185,13 +207,14 @@
 	 * 
 	 * @param osm The object to delete.
-	 */
-	private void delete(OsmPrimitive osm) {
-		if (osm instanceof Node && isReferenced((Node)osm)) {
-			combineAndDelete((Node)osm);
-			return;
-		}
+	 * @param msgBox Whether a message box for errors should be shown
+	 * @return <code>true</code> if the object could be deleted
+	 */
+	private boolean delete(OsmPrimitive osm, boolean msgBox) {
+		if (osm instanceof Node && isReferenced((Node)osm))
+			return combineAndDelete((Node)osm, msgBox);
 		Collection<OsmPrimitive> c = new LinkedList<OsmPrimitive>();
 		c.add(osm);
-		mv.editLayer().add(new DeleteCommand(c));
+		mv.editLayer().add(new DeleteCommand(Main.main.ds, c));
+		return true;
 	}
 
@@ -203,9 +226,5 @@
 	 */
 	private boolean isReferenced(Node n) {
-		for (Track t : Main.main.ds.tracks)
-			for (LineSegment ls : t.segments)
-				if (ls.start == n || ls.end == n)
-					return true;
-		for (LineSegment ls : Main.main.ds.pendingLineSegments)
+		for (LineSegment ls : Main.main.ds.lineSegments)
 			if (ls.start == n || ls.end == n)
 				return true;
@@ -220,108 +239,51 @@
 	 *
 	 * @param n The node that is going to be deleted.
-	 * @return <code>null</code> if combining suceded or an error string if there
-	 * 		are problems combining the node.
-	 */
-	private void combineAndDelete(Node n) {
-		// first, check for pending line segments
-		for (LineSegment ls : Main.main.ds.pendingLineSegments)
-			if (n == ls.start || n == ls.end) {
-				JOptionPane.showMessageDialog(Main.main, "Node used by a line segment which is not part of any track. Remove this first.");
-				return;
-			}
-		
-		// These line segments must be combined within the track combining
-		ArrayList<LineSegment> pendingLineSegmentsForTrack = new ArrayList<LineSegment>();
-
-		// try to combine line segments
-		
-		// These line segments are combinable. The inner arraylist has always 
-		// two elements. The keys maps to the track, the line segments are in.
-		Collection<LineSegmentCombineEntry> lineSegments = new ArrayList<LineSegmentCombineEntry>();
-		
-		for (Track t : Main.main.ds.tracks) {
-			ArrayList<LineSegment> current = new ArrayList<LineSegment>();
-			for (LineSegment ls : t.segments)
-				if (ls.start == n || ls.end == n)
-					current.add(ls);
-			if (!current.isEmpty()) {
-				if (current.size() > 2) {
-					JOptionPane.showMessageDialog(Main.main, "Node used by more than two line segments.");
-					return;
-				}
-				if (current.size() == 1 && 
-						(current.get(0) == t.getStartingSegment() || current.get(0) == t.getEndingSegment()))
-					pendingLineSegmentsForTrack.add(current.get(0));
-				else if (current.get(0).end != current.get(1).start &&
-						current.get(1).end != current.get(0).start) {
-					JOptionPane.showMessageDialog(Main.main, "Node used by line segments that points together.");
-					return;
-				} else if (!current.get(0).keyPropertiesMergable(current.get(1))) {
-					JOptionPane.showMessageDialog(Main.main, "Node used by line segments with different properties.");
-					return;
-				} else {
-					LineSegmentCombineEntry e = new LineSegmentCombineEntry();
-					e.first = current.get(0);
-					e.second = current.get(1);
-					e.track = t;
-					lineSegments.add(e);
-				}
-			}
-		}
-		
-		// try to combine tracks
-		ArrayList<Track> tracks = new ArrayList<Track>();
-		for (Track t : Main.main.ds.tracks)
-			if (t.getStartingNode() == n || t.getEndingNode() == n)
-				tracks.add(t);
-		if (!tracks.isEmpty()) {
-			if (tracks.size() > 2) {
-				JOptionPane.showMessageDialog(Main.main, "Node used by more than two tracks.");
-				return;
-			}
-			if (tracks.size() == 1) {
-				JOptionPane.showMessageDialog(Main.main, "Node used by a track.");
-				return;
-			}
-			Track t1 = tracks.get(0);
-			Track t2 = tracks.get(1);
-			if (t1.getStartingNode() != t2.getEndingNode() &&
-					t2.getStartingNode() != t1.getEndingNode()) {
-				if (t1.getStartingNode() == t2.getStartingNode() ||
-						t1.getEndingNode() == t2.getEndingNode()) {
-					JOptionPane.showMessageDialog(Main.main, "Node used by tracks that point together.");
-					return;
-				}
-				JOptionPane.showMessageDialog(Main.main, "Node used by tracks that cannot be combined.");
-				return;
-			}
-			if (!t1.keyPropertiesMergable(t2)) {
-				JOptionPane.showMessageDialog(Main.main, "Node used by tracks with different properties.");
-				return;
-			}
-		}
-		
-		// try to match the pending line segments
-		if (pendingLineSegmentsForTrack.size() == 2) {
-			LineSegment l1 = pendingLineSegmentsForTrack.get(0);
-			LineSegment l2 = pendingLineSegmentsForTrack.get(1);
-			if (l1.start == l2.start || l1.end == l2.end) {
-				JOptionPane.showMessageDialog(Main.main, "Node used by line segments that points together.");
-				return;
-			}
-			if (l1.start == l2.end || l2.start == l1.end)
-				pendingLineSegmentsForTrack.clear(); // resolved.
-		}
-		
-		// still pending line segments?
-		if (!pendingLineSegmentsForTrack.isEmpty()) {
-			JOptionPane.showMessageDialog(Main.main, "Node used by tracks that cannot be combined.");
-			return;
+	 * @param msgBox Whether a message box should be displayed in case of problems
+	 * @return <code>true</code> if combining suceded.
+	 */
+	private boolean combineAndDelete(Node n, boolean msgBox) {
+		DataSet ds = Main.main.ds;
+		Collection<LineSegment> lineSegmentsUsed = new HashSet<LineSegment>();
+		for (LineSegment ls : ds.lineSegments)
+			if (ls.start == n || ls.end == n)
+				lineSegmentsUsed.add(ls);
+
+		if (lineSegmentsUsed.isEmpty())
+			// should not be called
+			throw new IllegalStateException();
+		
+		if (lineSegmentsUsed.size() == 1) {
+			if (msgBox)
+				JOptionPane.showMessageDialog(Main.main, "Node used by a line segment. Delete this first.");
+			return false;
+		}
+			
+		if (lineSegmentsUsed.size() > 2) {
+			if (msgBox)
+				JOptionPane.showMessageDialog(Main.main, "Node used by more than two line segments. Delete them first.");
+			return false;
+		}
+		
+		Iterator<LineSegment> it = lineSegmentsUsed.iterator();
+		LineSegment first = it.next();
+		LineSegment second = it.next();
+		
+		// wrong direction?
+		if (first.start == second.end) {
+			LineSegment t = first;
+			first = second;
+			second = t;
+		}
+		
+		// combinable?
+		if (first.end != second.start || !first.end.keyPropertiesMergable(second.start)) {
+			if (msgBox)
+				JOptionPane.showMessageDialog(Main.main, "Node used by line segments that cannot be combined.");
+			return false;
 		}
 
 		// Ok, we can combine. Do it.
-		Track firstTrack = tracks.isEmpty() ? null : tracks.get(0);
-		Track secondTrack = tracks.isEmpty() ? null : tracks.get(1);
-		mv.editLayer().add(new CombineAndDeleteCommand(n, lineSegments, firstTrack, secondTrack));
+		mv.editLayer().add(new CombineAndDeleteCommand(ds, first, second));
+		return true;
 	}
 }
Index: /src/org/openstreetmap/josm/actions/mapmode/MapMode.java
===================================================================
--- /src/org/openstreetmap/josm/actions/mapmode/MapMode.java	(revision 29)
+++ /src/org/openstreetmap/josm/actions/mapmode/MapMode.java	(revision 30)
@@ -6,9 +6,5 @@
 import java.awt.event.MouseMotionListener;
 
-import javax.swing.AbstractAction;
-import javax.swing.JComponent;
-import javax.swing.KeyStroke;
-
-import org.openstreetmap.josm.gui.ImageProvider;
+import org.openstreetmap.josm.actions.JosmAction;
 import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.MapView;
@@ -22,5 +18,5 @@
  * control. 
  */
-abstract public class MapMode extends AbstractAction implements MouseListener, MouseMotionListener {
+abstract public class MapMode extends JosmAction implements MouseListener, MouseMotionListener {
 
 	/**
@@ -40,10 +36,5 @@
 	 */
 	public MapMode(String name, String iconName, String tooltip, int mnemonic, MapFrame mapFrame) {
-		super(name, ImageProvider.get("mapmode", iconName));
-		putValue(MNEMONIC_KEY, mnemonic);
-		putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(mnemonic,0));
-		putValue(LONG_DESCRIPTION, tooltip);
-		mapFrame.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(mnemonic,0), this);
-		mapFrame.getActionMap().put(this, this);
+		super(name, "mapmode/"+iconName, tooltip, mnemonic, null);
 		this.mapFrame = mapFrame;
 		mv = mapFrame.mapView;
Index: /src/org/openstreetmap/josm/command/AddCommand.java
===================================================================
--- /src/org/openstreetmap/josm/command/AddCommand.java	(revision 29)
+++ /src/org/openstreetmap/josm/command/AddCommand.java	(revision 30)
@@ -3,9 +3,8 @@
 import java.awt.Component;
 import java.util.Collection;
-import java.util.Iterator;
 
 import javax.swing.JLabel;
 
-import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Key;
 import org.openstreetmap.josm.data.osm.LineSegment;
@@ -22,6 +21,33 @@
  * @author imi
  */
-public class AddCommand implements Command, Visitor {
+public class AddCommand implements Command {
 
+	/**
+	 * The dataset this command operates on.
+	 */
+	DataSet ds;
+
+	/**
+	 * Helper that adds the object
+	 * @author imi
+	 */
+	private final class AddVisitor implements Visitor {
+		public void visit(Node n) {ds.nodes.add(n);}
+		public void visit(LineSegment ls) {ds.lineSegments.add(ls);}
+		public void visit(Track t) {ds.tracks.add(t);}
+		public void visit(Key k) {throw new IllegalStateException("Keys are added by using ChangeKeyValueCommand");}
+	}
+
+	/**
+	 * Helper that deletes the object (for undo)
+	 * @author imi
+	 */
+	private final class RemoveVisitor implements Visitor {
+		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) {throw new IllegalStateException("Keys are added by using ChangeKeyValueCommand");}
+	}
+	
 	/**
 	 * The primitive to add to the dataset.
@@ -32,12 +58,17 @@
 	 * Create the command and specify the element to add.
 	 */
-	public AddCommand(OsmPrimitive osm) {
+	public AddCommand(DataSet ds, OsmPrimitive osm) {
+		this.ds = ds;
 		this.osm = osm;
 	}
 
 	public void executeCommand() {
-		osm.visit(this);
+		osm.visit(new AddVisitor());
 	}
-	
+
+	public void undoCommand() {
+		osm.visit(new RemoveVisitor());
+	}
+
 	public Component commandDescription() {
 		SelectionComponentVisitor v = new SelectionComponentVisitor();
@@ -47,47 +78,5 @@
 	
 	public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
-		if (added != null && !added.contains(osm))
-			added.add(osm);
-	}
-
-	/**
-	 * Add the node to the nodes - list only.
-	 * @param n The node to add.
-	 */
-	public void visit(Node n) {
-		Main.main.ds.nodes.add(n);
-	}
-
-	/**
-	 * Add the line segment to the list of pending line segments.
-	 * @param ls The line segment to add.
-	 */
-	public void visit(LineSegment ls) {
-		Main.main.ds.pendingLineSegments.add(ls);
-		Main.main.ds.addBackReference(ls.start, ls);
-		Main.main.ds.addBackReference(ls.end, ls);
-	}
-
-	/**
-	 * Add the track to the dataset. Remove all line segments that were pending
-	 * from the dataset.
-	 */
-	public void visit(Track t) {
-		Main.main.ds.tracks.add(t);
-		for (Iterator<LineSegment> it =  Main.main.ds.pendingLineSegments.iterator(); it.hasNext();)
-			if (t.segments.contains(it.next()))
-				it.remove();
-		for (LineSegment ls : t.segments) {
-			Main.main.ds.addBackReference(ls, t);
-			Main.main.ds.addBackReference(ls.start, t);
-			Main.main.ds.addBackReference(ls.end, t);
-		}
-	}
-
-	/**
-	 * Add the key to the parent specified by the constructor
-	 */
-	public void visit(Key k) {
-		throw new IllegalStateException("Keys are added by using ChangeKeyValueCommand");
+		added.add(osm);
 	}
 }
Index: /src/org/openstreetmap/josm/command/ChangeKeyValueCommand.java
===================================================================
--- /src/org/openstreetmap/josm/command/ChangeKeyValueCommand.java	(revision 29)
+++ /src/org/openstreetmap/josm/command/ChangeKeyValueCommand.java	(revision 30)
@@ -4,4 +4,8 @@
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
 
 import javax.swing.JLabel;
@@ -21,5 +25,5 @@
 	 * All primitives, that are affected with this command.
 	 */
-	private final Collection<OsmPrimitive> objects;
+	private final List<OsmPrimitive> objects;
 	/**
 	 * The key that is subject to change.
@@ -32,7 +36,12 @@
 	 */
 	private final String value;
+	
+	/**
+	 * These are the old values of the objects to do a proper undo.
+	 */
+	private List<Map<Key, String>> oldProperties;
 
 	public ChangeKeyValueCommand(Collection<OsmPrimitive> objects, Key key, String value) {
-		this.objects = objects;
+		this.objects = new LinkedList<OsmPrimitive>(objects);
 		this.key = key;
 		this.value = value;
@@ -40,4 +49,9 @@
 	
 	public void executeCommand() {
+		// save old
+		oldProperties = new LinkedList<Map<Key, String>>();
+		for (OsmPrimitive osm : objects)
+			oldProperties.add(osm.keys == null ? null : new HashMap<Key, String>(osm.keys));
+			
 		if (value == null) {
 			for (OsmPrimitive osm : objects) {
@@ -57,4 +71,10 @@
 	}
 
+	public void undoCommand() {
+		Iterator<Map<Key, String>> it = oldProperties.iterator();
+		for (OsmPrimitive osm : objects)
+			osm.keys = it.next();
+	}
+
 	public Component commandDescription() {
 		String objStr = objects.size()+" object" + (objects.size()==1?"":"s");
Index: /src/org/openstreetmap/josm/command/CombineAndDeleteCommand.java
===================================================================
--- /src/org/openstreetmap/josm/command/CombineAndDeleteCommand.java	(revision 29)
+++ /src/org/openstreetmap/josm/command/CombineAndDeleteCommand.java	(revision 30)
@@ -3,13 +3,15 @@
 import java.awt.Component;
 import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
 import java.util.Map;
 
 import javax.swing.JLabel;
 
-import org.openstreetmap.josm.Main;
 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.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Track;
@@ -19,4 +21,10 @@
  * This is a combination of first combining objects to get a node free of 
  * references and then delete that node. It is used by the delete action.
+ * 
+ * The rules is as follow:
+ * If the node to delete is between exact two line segments, which are
+ * in a straight (not pointing together), the second line segment is deleted
+ * and the first now spans to the last node of the second line segment.
+ * 
  * @author imi
  */
@@ -24,77 +32,91 @@
 
 	/**
-	 * This class is used as one line segment pair that needs to get combined
-	 * for the node to be deleted.
-	 * @author imi
+	 * The dataset, this command operates on.
 	 */
-	public static class LineSegmentCombineEntry {
-		public LineSegment first, second;
-		public Track track;
-	}
+	private DataSet ds;
+	/**
+	 * This line segment is combined with the second line segment.
+	 * The node that get deleted is the end of this segment.
+	 */
+	private LineSegment first;
+	/**
+	 * This line segment is deleted by the combining.
+	 * The node that get deleted is the start of this segment.
+	 */
+	private LineSegment second;
+
+	/**
+	 * The tracks (if any) the line segments are part of.
+	 */
+	private List<Track> track;
+
+	
+	// stuff for undo
+
+	/**
+	 * The old properties of the first line segment (for undo)
+	 */
+	private Map<Key, String> oldProperties;
+	/**
+	 * The positions of the second line segment in the tracks (if any track)
+	 */
+	private List<Integer> lineSegmentTrackPos;
 	
 	/**
-	 * The node that get deleted
+	 * Create the command and assign the data entries.
+	 * @param ds     The dataset this command operates on.
+	 * @param first  The line segment that remain alive
+	 * @param second The line segment that get deleted
 	 */
-	private Node node;
-	/**
-	 * These line segments are 
-	 */
-	private Collection<LineSegmentCombineEntry> combineLineSegments;
-	/**
-	 * These tracks are combined
-	 */
-	private Track firstTrack, secondTrack;
-	/**
-	 * This line segment is deleted together with the second track. It was the
-	 * first segment of the second track (the other line segments were integrated
-	 * into the first track).
-	 */
-	private LineSegment firstOfSecond;
-
-	/**
-	 * Create the command and assign the data entries.
-	 */
-	public CombineAndDeleteCommand(Node nodeToDelete, 
-			Collection<LineSegmentCombineEntry> combineLineSegments,
-			Track firstTrack, Track secondTrack) {
-		node = nodeToDelete;
-		this.combineLineSegments = combineLineSegments;
-		this.firstTrack = firstTrack;
-		this.secondTrack = secondTrack;
+	public CombineAndDeleteCommand(DataSet ds, LineSegment first, LineSegment second) {
+		this.ds = ds;
+		this.first = first;
+		this.second = second;
+		if (first.end != second.start)
+			throw new IllegalArgumentException();
 	}
 	
 	public void executeCommand() {
-		// line segments
-		DataSet ds = Main.main.ds;
-		for (LineSegmentCombineEntry e : combineLineSegments) {
-			if (e.first.start == e.second.end) {
-				LineSegment tmp = e.first;
-				e.first = e.second;
-				e.second = tmp;
+		first.end = second.end;
+		oldProperties = new HashMap<Key, String>(first.keys);
+		first.keys = mergeKeys(first.keys, second.keys);
+
+		// delete second line segment
+		for (Track t : ds.tracks) {
+			if (t.segments.contains(second)) {
+				if (track == null)
+					track = new LinkedList<Track>();
+				track.add(t);
 			}
-			e.first.end = e.second.end;
-			e.first.keys = mergeKeys(e.first.keys, e.second.keys);
-			e.track.segments.remove(e.second);
 		}
+		if (track != null) {
+			lineSegmentTrackPos = new LinkedList<Integer>();
+			for (Track t : track) {
+				int i = t.segments.indexOf(second);
+				if (i != -1)
+					t.segments.remove(second);
+				lineSegmentTrackPos.add(i);
+			}
+		}
+		ds.lineSegments.remove(second);
 		
-		// tracks
-		if (firstTrack != null && secondTrack != null) {
-			if (firstTrack.getStartingNode() == secondTrack.getEndingNode()) {
-				Track t = firstTrack;
-				firstTrack = secondTrack;
-				secondTrack = t;
+		// delete node
+		ds.nodes.remove(second.start);
+	}
+
+	public void undoCommand() {
+		ds.nodes.add(second.start);
+		ds.lineSegments.add(second);
+		
+		if (track != null) {
+			Iterator<Track> it = track.iterator();
+			for (int i : lineSegmentTrackPos) {
+				Track t = it.next();
+				if (i != -1)
+					t.segments.add(i, second);
 			}
-			// concatenate the line segments.
-			LineSegment lastOfFirst = firstTrack.getEndingSegment();
-			firstOfSecond = secondTrack.getStartingSegment();
-			lastOfFirst.end = firstOfSecond.end;
-			lastOfFirst.keys = mergeKeys(lastOfFirst.keys, firstOfSecond.keys);
-			secondTrack.segments.remove(firstOfSecond);
-			// move the remaining line segments to first track.
-			firstTrack.segments.addAll(secondTrack.segments);
-			ds.tracks.remove(secondTrack);
 		}
-		ds.nodes.remove(node);
-		ds.rebuildBackReferences();
+		first.keys = oldProperties;
+		first.end = second.start;
 	}
 
@@ -115,21 +137,14 @@
 	public Component commandDescription() {
 		SelectionComponentVisitor v = new SelectionComponentVisitor();
-		v.visit(node);
+		v.visit(second.start);
 		return new JLabel("Remove "+v.name, v.icon, JLabel.LEADING);
 	}
 
 	public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
-		deleted.add(node);
-		if (firstTrack != null)
-			modified.add(firstTrack);
-		if (secondTrack != null)
-			deleted.add(secondTrack);
-		if (firstOfSecond != null)
-			deleted.add(firstOfSecond);
-		for (LineSegmentCombineEntry e : combineLineSegments) {
-			modified.add(e.first);
-			deleted.add(e.second);
-			modified.add(e.track);
-		}
+		deleted.add(second);
+		deleted.add(second.start);
+		modified.add(first);
+		if (track != null)
+			modified.addAll(track);
 	}
 
Index: c/org/openstreetmap/josm/command/CombineCommand.java
===================================================================
--- /src/org/openstreetmap/josm/command/CombineCommand.java	(revision 29)
+++ 	(revision )
@@ -1,90 +1,0 @@
-package org.openstreetmap.josm.command;
-
-import java.awt.Component;
-import java.util.Collection;
-
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-
-import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.data.osm.LineSegment;
-import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.data.osm.Track;
-import org.openstreetmap.josm.data.osm.visitor.SelectionComponentVisitor;
-
-/**
- * This command combines either a line segment with a track or two tracks together.
- * @author imi
- */
-public class CombineCommand implements Command {
-
-	/**
-	 * Both primitives that get combined together. "mod" is modified to be the combined
-	 * object and del is the deleted one.
-	 */
-	private final OsmPrimitive mod, del;
-	
-	/**
-	 * Create a combine command and assign the members
-	 */
-	public CombineCommand(OsmPrimitive first, OsmPrimitive second) {
-		if (first instanceof Track && second instanceof LineSegment) {
-			mod = first;
-			del = second;
-		} else if (first instanceof LineSegment && second instanceof Track) {
-			mod = second;
-			del = first;
-		} else if (((Track)first).getStartingNode() == ((Track)second).getEndingNode()) {
-			mod = first;
-			del = second;
-		} else {
-			mod = second;
-			del = first;
-		}
-	}
-
-	public void executeCommand() {
-		if (del instanceof LineSegment) {
-			LineSegment ls = (LineSegment)del;
-			Track t = (Track)mod;
-			if (!Main.main.ds.pendingLineSegments.contains(ls))
-				throw new IllegalStateException("Should not be able to select non-pending line segments.");
-			
-			Main.main.ds.pendingLineSegments.remove(ls);
-			if (t.getStartingNode() != ls.end)
-				t.add(ls);
-			else
-				t.segments.add(0,ls);
-		} else {
-			Track t1 = (Track)mod;
-			Track t2 = (Track)del;
-			t1.segments.addAll(t2.segments);
-			if (t1.keys == null)
-				t1.keys = t2.keys;
-			else	
-				t1.keys.putAll(t2.keys);
-			Main.main.ds.tracks.remove(t2);
-		}
-		Main.main.ds.rebuildBackReferences();
-	}
-
-	public Component commandDescription() {
-		JPanel p = new JPanel();
-		p.add(new JLabel("Combine"));
-		SelectionComponentVisitor v = new SelectionComponentVisitor();
-		mod.visit(v);
-		p.add(new JLabel(v.name, v.icon, JLabel.LEADING));
-		p.add(new JLabel("with"));
-		del.visit(v);
-		p.add(new JLabel(v.name, v.icon, JLabel.LEADING));
-		return p;
-	}
-	
-	public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
-		if (modified != null && !modified.contains(mod))
-			modified.add(mod);
-		if (deleted != null && deleted.contains(del))
-			throw new IllegalStateException("Deleted object twice: "+del);
-		deleted.add(del);
-	}
-}
Index: /src/org/openstreetmap/josm/command/Command.java
===================================================================
--- /src/org/openstreetmap/josm/command/Command.java	(revision 29)
+++ /src/org/openstreetmap/josm/command/Command.java	(revision 30)
@@ -11,4 +11,8 @@
  * one atomic action on a specific dataset, such as move or delete.
  *
+ * Remember, that the command must be executable and undoable, even if the 
+ * Main.main.ds has changed, so the command must save the dataset it operates on
+ * if necessary.
+ *
  * @author imi
  */
@@ -21,4 +25,11 @@
 
 	/**
+	 * Undoes the command. 
+	 * It can be assumed, that all objects are in the same state they were before.
+	 * It can also be assumed that executeCommand was called exactly once before.
+	 */
+	void undoCommand();
+	
+	/**
 	 * Give a description of the command as component to draw
 	 */
@@ -26,11 +37,10 @@
 	
 	/**
-	 * Fill in the changed data this command operates on (for sending to the server).
-	 * Add to the lists, don't clear them. The lists can be <code>null</code>
-	 * in which case they are ignored.
+	 * Fill in the changed data this command operates on.
+	 * Add to the lists, don't clear them.
 	 * 
-	 * @param modified  The modified primitives or <code>null</code>
-	 * @param deleted   The deleted primitives or <code>null</code>
-	 * @param added		The added primitives or <code>null</code>
+	 * @param modified  The modified primitives
+	 * @param deleted   The deleted primitives
+	 * @param added		The added primitives
 	 */
 	void fillModifiedData(Collection<OsmPrimitive> modified,
Index: /src/org/openstreetmap/josm/command/DeleteCommand.java
===================================================================
--- /src/org/openstreetmap/josm/command/DeleteCommand.java	(revision 29)
+++ /src/org/openstreetmap/josm/command/DeleteCommand.java	(revision 30)
@@ -3,9 +3,8 @@
 import java.awt.Component;
 import java.util.Collection;
-import java.util.LinkedList;
 
 import javax.swing.JLabel;
 
-import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Key;
 import org.openstreetmap.josm.data.osm.LineSegment;
@@ -19,6 +18,35 @@
  * @author imi
  */
-public class DeleteCommand implements Command, Visitor {
+public class DeleteCommand implements Command {
 
+	/**
+	 * The dataset this command operates on.
+	 */
+	DataSet ds;
+
+	/**
+	 * Helper that adds the object.
+	 * @author imi
+	 */
+	private final class AddVisitor implements Visitor {
+		public void visit(Node n) {ds.nodes.add(n);}
+		public void visit(LineSegment ls) {ds.lineSegments.add(ls);}
+		public void visit(Track t) {ds.tracks.add(t);}
+		public void visit(Key k) {throw new IllegalStateException("Keys are added by using ChangeKeyValueCommand");}
+	}
+
+	/**
+	 * Helper that deletes the object. Does not respect back reference cache.
+	 * @author imi
+	 */
+	private final class DeleteVisitor implements Visitor {
+		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) {throw new IllegalStateException("Keys are added by using ChangeKeyValueCommand");}
+	}
+	
+	
+	
 	/**
 	 * The primitives that are going to deleted.
@@ -26,11 +54,19 @@
 	private final Collection<OsmPrimitive> data;
 	
-	public DeleteCommand(Collection<OsmPrimitive> data) {
+	public DeleteCommand(DataSet ds, Collection<OsmPrimitive> data) {
+		this.ds = ds;
 		this.data = data;
 	}
 	
 	public void executeCommand() {
+		Visitor v = new DeleteVisitor();
 		for (OsmPrimitive osm : data)
-			osm.visit(this);
+			osm.visit(v);
+	}
+
+	public void undoCommand() {
+		Visitor v = new AddVisitor();
+		for (OsmPrimitive osm : data)
+			osm.visit(v);
 	}
 
@@ -39,41 +75,6 @@
 	}
 
-	public void fillModifiedData(Collection<OsmPrimitive> modified,
-			Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
-		if (deleted != null)
-			deleted.addAll(data);
+	public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
+		deleted.addAll(data);
 	}
-
-
-	public void visit(Node n) {
-		Main.main.ds.nodes.remove(n);
-		Main.main.ds.removeBackReference(n);
-	}
-
-	public void visit(LineSegment ls) {
-		Main.main.ds.pendingLineSegments.remove(ls);
-		LinkedList<Track> tracksToDelete = new LinkedList<Track>();
-		for (Track t : Main.main.ds.tracks) {
-			t.segments.remove(ls);
-			if (t.segments.isEmpty())
-				tracksToDelete.add(t);
-		}
-		for (Track t : tracksToDelete) {
-			Main.main.ds.tracks.remove(t);
-			Main.main.ds.removeBackReference(t);
-		}
-		Main.main.ds.removeBackReference(ls);
-	}
-
-	public void visit(Track t) {
-		Main.main.ds.tracks.remove(t);
-		for (LineSegment ls : t.segments)
-			Main.main.ds.pendingLineSegments.add(ls);
-		Main.main.ds.removeBackReference(t);
-	}
-
-	public void visit(Key k) {
-		// TODO
-	}
-
 }
Index: /src/org/openstreetmap/josm/command/MoveCommand.java
===================================================================
--- /src/org/openstreetmap/josm/command/MoveCommand.java	(revision 29)
+++ /src/org/openstreetmap/josm/command/MoveCommand.java	(revision 30)
@@ -2,5 +2,9 @@
 
 import java.awt.Component;
+import java.awt.geom.Point2D;
 import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
 
 import javax.swing.JLabel;
@@ -21,5 +25,5 @@
 	 * The objects that should be moved.
 	 */
-	private Collection<OsmPrimitive> objects;
+	private List<OsmPrimitive> objects;
 	/**
 	 * x difference movement. Coordinates are in northern/eastern 
@@ -32,18 +36,15 @@
 
 	/**
+	 * x/y List of all old positions of the objects.
+	 */
+	private List<Point2D.Double> oldPositions;
+	
+	/**
 	 * Create a MoveCommand and assign the initial object set and movement vector.
 	 */
 	public MoveCommand(Collection<OsmPrimitive> objects, double x, double y) {
-		this.objects = objects;
+		this.objects = new LinkedList<OsmPrimitive>(objects);
 		this.x = x;
 		this.y = y;
-	}
-
-	/**
-	 * Move the objects additional to the current movement.
-	 */
-	public void move(double x, double y) {
-		this.x += x;
-		this.y += y;
 	}
 
@@ -58,4 +59,16 @@
 	}
 
+	public void undoCommand() {
+		AllNodesVisitor visitor = new AllNodesVisitor();
+		for (OsmPrimitive osm : objects)
+			osm.visit(visitor);
+		Iterator<Point2D.Double> it = oldPositions.iterator();
+		for (Node n : visitor.nodes) {
+			Point2D.Double p = it.next();
+			n.coor.x = p.x;
+			n.coor.y = p.y;
+		}
+	}
+
 	public Component commandDescription() {
 		String xstr = Math.abs(x) + (x < 0 ? "W" : "E");
@@ -65,8 +78,7 @@
 
 	public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
-		if (modified != null)
-			for (OsmPrimitive osm : objects)
-				if (!modified.contains(osm))
-					modified.add(osm);
+		for (OsmPrimitive osm : objects)
+			if (!modified.contains(osm))
+				modified.add(osm);
 	}
 }
Index: /src/org/openstreetmap/josm/data/Preferences.java
===================================================================
--- /src/org/openstreetmap/josm/data/Preferences.java	(revision 29)
+++ /src/org/openstreetmap/josm/data/Preferences.java	(revision 30)
@@ -45,8 +45,4 @@
 	 */
 	private boolean drawRawGpsLines = false;
-	/**
-	 * Whether deleted objects should be drawn in a dark color.
-	 */
-	private boolean drawDeleted = false;
 	/**
 	 * Force the drawing of lines between raw gps points if there are no
@@ -139,5 +135,4 @@
 			drawRawGpsLines = root.getChild("drawRawGpsLines") != null;
 			forceRawGpsLines = root.getChild("forceRawGpsLines") != null;
-			drawDeleted = root.getChild("drawDeleted") != null;
 		} catch (Exception e) {
 			if (e instanceof PreferencesException)
@@ -162,6 +157,4 @@
 		if (drawRawGpsLines)
 			children.add(new Element("drawRawGpsLines"));
-		if (drawDeleted)
-			children.add(new Element("drawDeleted"));
 		if (forceRawGpsLines)
 			children.add(new Element("forceRawGpsLines"));
@@ -256,11 +249,3 @@
 		return forceRawGpsLines;
 	}
-	public boolean isDrawDeleted() {
-		return drawDeleted;
-	}
-	public void setDrawDeleted(boolean drawDeleted) {
-		boolean old = this.drawDeleted;
-		this.drawDeleted = drawDeleted;
-		firePropertyChanged("drawDeleted", old, drawDeleted);
-	}
 }
Index: /src/org/openstreetmap/josm/data/osm/DataSet.java
===================================================================
--- /src/org/openstreetmap/josm/data/osm/DataSet.java	(revision 29)
+++ /src/org/openstreetmap/josm/data/osm/DataSet.java	(revision 30)
@@ -6,22 +6,19 @@
 import java.util.LinkedList;
 import java.util.Map;
-import java.util.Set;
 
 import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.data.SelectionTracker;
-import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor;
 
 /**
- * DataSet is the data behind one window in the application. It can consist of only a few
- * points up to the whole osm database. DataSet's can be merged together, split up into
- * several different ones, saved, (up/down/disk)loaded etc.
+ * DataSet is the data behind the application. It can consist of only a few
+ * points up to the whole osm database. DataSet's can be merged together, 
+ * saved, (up/down/disk)loaded etc.
  *
- * Note, that DataSet is not an osm-primitive, it is not within 
- * org.openstreetmap.josm.data.osm and has no key association but a few
- * members to store some information.
+ * Note, that DataSet is not an osm-primitive and so has no key association 
+ * but a few members to store some information.
  * 
  * @author imi
  */
-public class DataSet extends SelectionTracker implements Cloneable {
+public class DataSet extends SelectionTracker {
 
 	/**
@@ -33,8 +30,7 @@
 
 	/**
-	 * All pending line segments goes here. Pending line segments are those, that 
-	 * are in this list but are in no track.
-	 */
-	public Collection<LineSegment> pendingLineSegments = new LinkedList<LineSegment>();
+	 * All line segments goes here, even when they are in a track.
+	 */
+	public Collection<LineSegment> lineSegments = new LinkedList<LineSegment>();
 
 	/**
@@ -47,107 +43,4 @@
 	public Collection<Track> tracks = new LinkedList<Track>();
 
-	
-	/**
-	 * This is a list of all back references of nodes to their track usage.
-	 */
-	public Map<Node, Set<Track>> nodeTrackRef = new HashMap<Node, Set<Track>>();
-	/**
-	 * This is a list of all back references of nodes to their line segments.
-	 */
-	public Map<Node, Set<LineSegment>> nodeLsRef = new HashMap<Node, Set<LineSegment>>();
-	/**
-	 * This is a list of all back references of lines to their tracks.
-	 */
-	public Map<LineSegment, Set<Track>> lsTrackRef = new HashMap<LineSegment, Set<Track>>();
-
-	/**
-	 * Add a back reference from the node to the line segment.
-	 */
-	public void addBackReference(Node from, LineSegment to) {
-		Set<LineSegment> references = nodeLsRef.get(from);
-		if (references == null)
-			references = new HashSet<LineSegment>();
-		references.add(to);
-		nodeLsRef.put(from, references);
-	}
-	/**
-	 * Add a back reference from the node to the track.
-	 */
-	public void addBackReference(Node from, Track to) {
-		Set<Track> references = nodeTrackRef.get(from);
-		if (references == null)
-			references = new HashSet<Track>();
-		references.add(to);
-		nodeTrackRef.put(from, references);
-	}
-	/**
-	 * Add a back reference from the line segment to the track.
-	 */
-	public void addBackReference(LineSegment from, Track to) {
-		Set<Track> references = lsTrackRef.get(from);
-		if (references == null)
-			references = new HashSet<Track>();
-		references.add(to);
-		lsTrackRef.put(from, references);
-	}
-
-	/**
-	 * Removes all references to and from this line segment.
-	 */
-	public void removeBackReference(LineSegment ls) {
-		Set<LineSegment> s = nodeLsRef.get(ls.start);
-		if (s != null)
-			s.remove(ls);
-		s = nodeLsRef.get(ls.end);
-		if (s != null)
-			s.remove(ls);
-		lsTrackRef.remove(ls);
-	}
-	/**
-	 * Removes all references to and from the node.
-	 */
-	public void removeBackReference(Node n) {
-		nodeLsRef.remove(n);
-		nodeTrackRef.remove(n);
-	}
-	/**
-	 * Removes all references to and from the track.
-	 */
-	public void removeBackReference(Track t) {
-		Collection<Node> nodes = AllNodesVisitor.getAllNodes(t);
-		for (Node n : nodes) {
-			Set<Track> s = nodeTrackRef.get(n);
-			if (s != null)
-				s.remove(t);
-		}
-		for (LineSegment ls : t.segments) {
-			Set<Track> s = lsTrackRef.get(ls);
-			if (s != null)
-				s.remove(t);
-		}
-	}
-	
-	/**
-	 * Rebuild the caches of back references.
-	 */
-	public void rebuildBackReferences() {
-		nodeTrackRef.clear();
-		nodeLsRef.clear();
-		lsTrackRef.clear();
-		for (Track t : tracks) {
-			for (LineSegment ls : t.segments) {
-				addBackReference(ls.start, ls);
-				addBackReference(ls.end, ls);
-				addBackReference(ls.start, t);
-				addBackReference(ls.end, t);
-				addBackReference(ls, t);
-			}
-		}
-		for (LineSegment ls : pendingLineSegments) {
-			addBackReference(ls.start, ls);
-			addBackReference(ls.end, ls);
-		}
-	}
-	
 	/**
 	 * Return the bounds of this DataSet, depending on X/Y values.
@@ -218,8 +111,6 @@
 	public void clearSelection() {
 		clearSelection(nodes);
-		clearSelection(pendingLineSegments);
+		clearSelection(lineSegments);
 		clearSelection(tracks);
-		for (Track t : tracks)
-			clearSelection(t.segments);
 	}
 
@@ -231,8 +122,6 @@
 	public Collection<OsmPrimitive> getSelected() {
 		Collection<OsmPrimitive> sel = getSelected(nodes);
-		sel.addAll(getSelected(pendingLineSegments));
+		sel.addAll(getSelected(lineSegments));
 		sel.addAll(getSelected(tracks));
-		for (Track t : tracks)
-			sel.addAll(getSelected(t.segments));
 		return sel;
 	}
@@ -249,27 +138,13 @@
 	 * Tracks are merged, if they consist of the same line segments.
 	 *
-	 * Additional to that, every two objects with the same id are merged.
+	 * TODO Additional to that, every two objects with the same id are merged.
 	 *
 	 * @param ds	The DataSet to merge into this one.
-	 * @return A list of all primitives that were used in the conjunction. That
-	 * 		is all used primitives (the merged primitives and all added ones).
-	 */
-	public Collection<OsmPrimitive> mergeFrom(DataSet ds) {
-		Collection<OsmPrimitive> data = new LinkedList<OsmPrimitive>();
-
-		Set<LineSegment> myLineSegments = new HashSet<LineSegment>();
-		myLineSegments.addAll(pendingLineSegments);
-		for (Track t : tracks)
-			myLineSegments.addAll(t.segments);
+	 */
+	public void mergeFrom(DataSet ds) {
+		// merge nodes
 		
-		Set<LineSegment> otherLineSegments = new HashSet<LineSegment>();
-		otherLineSegments.addAll(ds.pendingLineSegments);
-		for (Track t : ds.tracks)
-			otherLineSegments.addAll(t.segments);
-		
-		
-		// merge nodes
-
 		Map<Node, Node> nodeMap = new HashMap<Node, Node>();
+
 		// find mergable
 		for (Node otherNode : ds.nodes)
@@ -278,13 +153,9 @@
 					nodeMap.put(otherNode, myNode);
 		// add
-		data.addAll(new HashSet<Node>(nodeMap.values()));
-		for (Node n : ds.nodes) {
-			if (!nodeMap.containsKey(n)) {
+		for (Node n : ds.nodes)
+			if (!nodeMap.containsKey(n))
 				nodes.add(n);
-				data.add(n);
-			}
-		}
 		// reassign
-		for (LineSegment ls : otherLineSegments) {
+		for (LineSegment ls : ds.lineSegments) {
 			Node n = nodeMap.get(ls.start);
 			if (n != null)
@@ -300,16 +171,12 @@
 		Map<LineSegment, LineSegment> lsMap = new HashMap<LineSegment, LineSegment>();
 		// find mergable
-		for (LineSegment otherLS : otherLineSegments)
-			for (LineSegment myLS : myLineSegments)
+		for (LineSegment otherLS : ds.lineSegments)
+			for (LineSegment myLS : lineSegments)
 				if (otherLS.start == myLS.start && otherLS.end == myLS.end)
 					lsMap.put(otherLS, myLS);
-		// add pendings (ls from track are added later
-		data.addAll(new HashSet<LineSegment>(lsMap.values()));
-		for (LineSegment ls : ds.pendingLineSegments) {
-			if (!lsMap.containsKey(ls)) {
-				pendingLineSegments.add(ls);
-				data.add(ls);
-			}
-		}
+		// add ls
+		for (LineSegment ls : ds.lineSegments)
+			if (!lsMap.containsKey(ls))
+				lineSegments.add(ls);
 		// reassign
 		for (Track t : ds.tracks) {
@@ -323,4 +190,5 @@
 
 		// merge tracks
+		
 		LinkedList<Track> trackToAdd = new LinkedList<Track>();
 		for (Track otherTrack : ds.tracks) {
@@ -329,5 +197,4 @@
 				if (myTrack.segments.equals(otherTrack.segments)) {
 					found = true;
-					data.add(myTrack);
 					break;
 				}
@@ -336,9 +203,5 @@
 				trackToAdd.add(otherTrack);
 		}
-		data.addAll(trackToAdd);
 		tracks.addAll(trackToAdd);
-
-		rebuildBackReferences();
-		return data;
 	}
 
@@ -373,10 +236,3 @@
 		return sel;
 	}
-
-
-	@Override
-	public DataSet clone() {
-		try {return (DataSet)super.clone();} catch (CloneNotSupportedException e) {}
-		return null;
-	}
 }
Index: /src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
===================================================================
--- /src/org/openstreetmap/josm/data/osm/OsmPrimitive.java	(revision 29)
+++ /src/org/openstreetmap/josm/data/osm/OsmPrimitive.java	(revision 30)
@@ -27,9 +27,4 @@
 	public long id = 0;
 
-	/**
-	 * If set to true, this object has been modified in the current session.
-	 */
-	transient public boolean modified = false;
-	
 	/**
 	 * If set to true, this object is currently selected.
Index: /src/org/openstreetmap/josm/data/osm/visitor/CsvVisitor.java
===================================================================
--- /src/org/openstreetmap/josm/data/osm/visitor/CsvVisitor.java	(revision 30)
+++ /src/org/openstreetmap/josm/data/osm/visitor/CsvVisitor.java	(revision 30)
@@ -0,0 +1,79 @@
+package org.openstreetmap.josm.data.osm.visitor;
+
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.util.Map.Entry;
+
+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.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.Track;
+
+/**
+ * Outputs the visited primitive as comma seperated value.
+ * @author imi
+ */
+public class CsvVisitor implements Visitor {
+
+	private final PrintWriter out;
+
+	/**
+	 * Construct the visitor.
+	 * @param out The stream, where the output should go to. 
+	 */
+	public CsvVisitor(Writer out) {
+		this.out = new PrintWriter(out);
+	}
+	
+	public void visit(Node n) {
+		out.print("n,"+common(n)+","+n.coor.lat+","+n.coor.lon+","+n.coor.x+","+n.coor.y);
+	}
+
+	public void visit(LineSegment ls) {
+		out.print("ls,"+common(ls)+",");
+		visit(ls.start);
+		out.print(',');
+		visit(ls.end);
+	}
+
+	public void visit(Track t) {
+		out.print("t,"+common(t)+","+t.segments.size());
+		for (LineSegment ls : t.segments) {
+			out.print(',');
+			visit(ls);
+		}
+	}
+
+	public void visit(Key k) {
+		//TODO
+	}
+
+	/**
+	 * Create a string for all common fields in the primitive
+	 * @param osm The primitive
+	 * @return A string containing the fields as csv.
+	 */
+	private String common(OsmPrimitive osm) {
+		StringBuilder b = new StringBuilder();
+		b.append(osm.id);
+		if (osm.keys != null) {
+			b.append(","+osm.keys.size());
+			for (Entry<Key, String> e : osm.keys.entrySet())
+				b.append(e.getKey().name+","+encode(e.getValue()));
+		} else
+			b.append(",0");
+		return b.toString();
+	}
+
+	/**
+	 * Encodes the string to be inserted as csv compatible value.
+	 * @param s The string to be inserted
+	 * @return The encoded string
+	 */
+	private String encode(String s) {
+		s = s.replace(",", "\\,");
+		s = s.replace("\n", "\\\n");
+		return s;
+	}
+}
Index: /src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
===================================================================
--- /src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java	(revision 29)
+++ /src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java	(revision 30)
@@ -4,7 +4,5 @@
 import java.awt.Graphics;
 import java.awt.Point;
-import java.util.Collection;
 
-import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.osm.Key;
 import org.openstreetmap.josm.data.osm.LineSegment;
@@ -51,56 +49,18 @@
 	/**
 	 * Draw a small rectangle. 
-	 * 
-	 * - White if selected (as always)
-	 * - Yellow, if not used by any tracks or areas.
-	 * - Green, if only used by pending line segments.
-	 * - Darkblue, if used in tracks but are only as inbound node. Inbound are
-	 *   all nodes, that have only line segments of the same track and
-	 *   at least two different line segments attached.
-	 * - Red otherwise (means, this is a dead end or is part of more than
-	 *   one track).
+	 * White if selected (as always) or red otherwise.
 	 * 
 	 * @param n The node to draw.
 	 */
 	public void visit(Node n) {
-		if (n.isSelected()) {
-			drawNode(n, Color.WHITE); // selected
-			return;
-		}
-
-		Collection<LineSegment> lineSegments = Main.main.ds.nodeLsRef.get(n);
-		if (lineSegments == null || lineSegments.isEmpty()) {
-			drawNode(n, Color.YELLOW); // single waypoint only
-			return;
-		}
-
-		Collection<Track> tracks = Main.main.ds.nodeTrackRef.get(n);
-		if (tracks == null || tracks.isEmpty()) {
-			drawNode(n, Color.GREEN); // pending line
-			return;
-		}
-		if (tracks.size() > 1) {
-			drawNode(n, Color.RED); // more than one track
-			return;
-		}
-		int segmentUsed = 0;
-		for (LineSegment ls : tracks.iterator().next().segments)
-			if (n == ls.start || n == ls.end)
-				++segmentUsed;
-		drawNode(n, segmentUsed > 1 ? darkblue : Color.RED);
+		drawNode(n, n.isSelected() ? Color.WHITE : Color.RED);
 	}
 
+	/**
+	 * Draw just a line between the points.
+	 * White if selected (as always) or green otherwise.
+	 */
 	public void visit(LineSegment ls) {
-		if (forceColor != null)
-			g.setColor(forceColor);
-		else if (ls.isSelected())
-			g.setColor(Color.WHITE);
-		else if (Main.main.ds.pendingLineSegments.contains(ls))
-			g.setColor(darkgreen);
-		else
-			g.setColor(darkblue);
-		Point p1 = mv.getScreenPoint(ls.start.coor);
-		Point p2 = mv.getScreenPoint(ls.end.coor);
-		g.drawLine(p1.x, p1.y, p2.x, p2.y);
+		drawLineSegment(ls, darkgreen);
 	}
 
@@ -111,7 +71,10 @@
 	public void visit(Track t) {
 		for (LineSegment ls : t.segments)
-			visit(ls);
+			drawLineSegment(ls, darkblue);
 	}
 
+	/**
+	 * Do not draw a key.
+	 */
 	public void visit(Key k) {
 	}
@@ -128,3 +91,17 @@
 		g.drawRect(p.x-1, p.y-1, 2, 2);
 	}
+
+	/**
+	 * Draw a line with the given color.
+	 */
+	private void drawLineSegment(LineSegment ls, Color col) {
+		if (forceColor != null)
+			col = forceColor;
+		else if (ls.isSelected())
+			col = Color.WHITE;
+		g.setColor(col);
+		Point p1 = mv.getScreenPoint(ls.start.coor);
+		Point p2 = mv.getScreenPoint(ls.end.coor);
+		g.drawLine(p1.x, p1.y, p2.x, p2.y);
+	}
 }
Index: /src/org/openstreetmap/josm/gui/IconToggleButton.java
===================================================================
--- /src/org/openstreetmap/josm/gui/IconToggleButton.java	(revision 29)
+++ /src/org/openstreetmap/josm/gui/IconToggleButton.java	(revision 30)
@@ -25,16 +25,7 @@
 		// Tooltip
 		String toolTipText = "";
-		Object o = action.getValue(Action.LONG_DESCRIPTION);
+		Object o = action.getValue(Action.SHORT_DESCRIPTION);
 		if (o != null)
-			toolTipText += o.toString();
-		o = action.getValue(Action.ACCELERATOR_KEY);
-		if (o != null) {
-			String ksName = o.toString();
-			if (ksName.startsWith("pressed "))
-				ksName = ksName.substring("pressed ".length());
-			else if (ksName.startsWith("released "))
-				ksName = ksName.substring("released ".length());
-			toolTipText += " Shortcut: "+ksName;
-		}
+			toolTipText = o.toString();
 		setToolTipText(toolTipText);
 		
Index: /src/org/openstreetmap/josm/gui/MapFrame.java
===================================================================
--- /src/org/openstreetmap/josm/gui/MapFrame.java	(revision 29)
+++ /src/org/openstreetmap/josm/gui/MapFrame.java	(revision 30)
@@ -4,10 +4,9 @@
 import java.awt.Component;
 import java.awt.Container;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 
 import javax.swing.AbstractButton;
+import javax.swing.BoxLayout;
 import javax.swing.ButtonGroup;
 import javax.swing.JPanel;
@@ -19,5 +18,4 @@
 import org.openstreetmap.josm.actions.mapmode.AddNodeAction;
 import org.openstreetmap.josm.actions.mapmode.AddTrackAction;
-import org.openstreetmap.josm.actions.mapmode.CombineAction;
 import org.openstreetmap.josm.actions.mapmode.DeleteAction;
 import org.openstreetmap.josm.actions.mapmode.MapMode;
@@ -54,4 +52,16 @@
 	 */
 	public MapStatus statusLine;
+	/**
+	 * The action to open the layer list
+	 */
+	private LayerList layerList;
+	/**
+	 * Action to open the properties panel for the selected objects
+	 */
+	private PropertiesDialog propertiesDialog;
+	/**
+	 * Action to open a list of all selected objects
+	 */
+	private SelectionListDialog selectionListDialog;
 
 	/**
@@ -76,5 +86,4 @@
 		toolBarActions.add(new IconToggleButton(this, new AddLineSegmentAction(this)));
 		toolBarActions.add(new IconToggleButton(this, new AddTrackAction(this)));
-		toolBarActions.add(new IconToggleButton(this, new CombineAction(this)));
 		toolBarActions.add(new IconToggleButton(this, new DeleteAction(this)));
 
@@ -99,20 +108,15 @@
 		});
 
-		// layer list
-		toolBarActions.add(new IconToggleButton(this, new LayerList(this)));
+		JPanel toggleDialogs = new JPanel();
+		add(toggleDialogs, BorderLayout.EAST);
+
+		toggleDialogs.setLayout(new BoxLayout(toggleDialogs, BoxLayout.Y_AXIS));
+		toolBarActions.add(new IconToggleButton(this, layerList = new LayerList(this)));
+		toggleDialogs.add(layerList);
+		toolBarActions.add(new IconToggleButton(this, propertiesDialog = new PropertiesDialog(this)));
+		toggleDialogs.add(propertiesDialog);
+		toolBarActions.add(new IconToggleButton(this, selectionListDialog = new SelectionListDialog(this)));
+		toggleDialogs.add(selectionListDialog);
 		
-		// properties
-		toolBarActions.add(new IconToggleButton(this, new PropertiesDialog(this)));
-
-		// selection dialog
-		SelectionListDialog selectionList = new SelectionListDialog(this);
-		final IconToggleButton buttonSelection = new IconToggleButton(this, selectionList);
-		selectionList.addWindowListener(new WindowAdapter(){
-			@Override
-			public void windowClosing(WindowEvent e) {
-				buttonSelection.setSelected(false);
-			}
-		});
-		toolBarActions.add(buttonSelection);
 
 		// status line below the map
Index: /src/org/openstreetmap/josm/gui/MapView.java
===================================================================
--- /src/org/openstreetmap/josm/gui/MapView.java	(revision 29)
+++ /src/org/openstreetmap/josm/gui/MapView.java	(revision 30)
@@ -20,4 +20,5 @@
 import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.data.GeoPoint;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.LineSegment;
 import org.openstreetmap.josm.data.osm.Node;
@@ -25,6 +26,6 @@
 import org.openstreetmap.josm.data.osm.Track;
 import org.openstreetmap.josm.data.projection.Projection;
-import org.openstreetmap.josm.gui.layer.EditLayer;
 import org.openstreetmap.josm.gui.layer.Layer;
+import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 
 /**
@@ -74,5 +75,5 @@
 	 * Direct link to the edit layer (if any) in the layers list.
 	 */
-	private EditLayer editLayer;
+	private OsmDataLayer editLayer;
 	/**
 	 * The layer from the layers list that is currently active.
@@ -109,25 +110,30 @@
 	 */
 	public void addLayer(Layer layer) {
-		if (layer instanceof EditLayer) {
+		// initialize the projection if it is the first layer
+		if (layers.isEmpty())
+			Main.pref.getProjection().init(layer.getBoundsLatLon());
+
+		// reinitialize layer's data
+		layer.init(Main.pref.getProjection());
+
+		if (layer instanceof OsmDataLayer) {
 			if (editLayer != null) {
-				// there can only be one EditLayer
+				// merge the layer into the existing one
+				if (!editLayer.isMergable(layer))
+					throw new IllegalArgumentException("Cannot merge argument");
 				editLayer.mergeFrom(layer);
+				repaint();
 				return;
 			}
-			editLayer = (EditLayer)layer;
-		}
-		
+			editLayer = (OsmDataLayer)layer;
+		}
+
+		// add as a new layer
 		layers.add(0,layer);
-
-		// initialize the projection if it is the first layer
-		if (layers.size() == 1)
-			Main.pref.getProjection().init(layer.getBoundsLatLon());
-
-		// reinitialize layer's data
-		layer.init(Main.pref.getProjection());
 
 		for (LayerChangeListener l : listeners)
 			l.layerAdded(layer);
 
+		// autoselect the new layer
 		setActiveLayer(layer);
 	}
@@ -248,5 +254,5 @@
 		
 		// pending line segments
-		for (LineSegment ls : Main.main.ds.pendingLineSegments) {
+		for (LineSegment ls : Main.main.ds.lineSegments) {
 			Point A = getScreenPoint(ls.start.coor);
 			Point B = getScreenPoint(ls.end.coor);
@@ -467,4 +473,5 @@
 	/**
 	 * Set the active selection to the given value and raise an layerchange event.
+	 * Also, swap the active dataset in Main.main if it is a datalayer.
 	 */
 	public void setActiveLayer(Layer layer) {
@@ -473,4 +480,6 @@
 		Layer old = activeLayer;
 		activeLayer = layer;
+		if (layer instanceof OsmDataLayer)
+			Main.main.ds = ((OsmDataLayer)layer).data;
 		if (old != layer) {
 			for (LayerChangeListener l : listeners)
@@ -491,7 +500,7 @@
 	 * 		So editLayer does never return <code>null</code>.
 	 */
-	public EditLayer editLayer() {
+	public OsmDataLayer editLayer() {
 		if (editLayer == null)
-			addLayer(new EditLayer(this));
+			addLayer(new OsmDataLayer(new DataSet(), "unnamed"));
 		return editLayer;
 	}
Index: /src/org/openstreetmap/josm/gui/PreferenceDialog.java
===================================================================
--- /src/org/openstreetmap/josm/gui/PreferenceDialog.java	(revision 29)
+++ /src/org/openstreetmap/josm/gui/PreferenceDialog.java	(revision 30)
@@ -62,5 +62,4 @@
 			Main.pref.setDrawRawGpsLines(drawRawGpsLines.isSelected());
 			Main.pref.setForceRawGpsLines(forceRawGpsLines.isSelected());
-			Main.pref.setDrawDeleted(drawDeleted.isSelected());
 			try {
 				Main.pref.save();
@@ -126,8 +125,4 @@
 	 */
 	JCheckBox forceRawGpsLines = new JCheckBox("Force lines if no line segments imported.");
-	/**
-	 * The checkbox stating whether deleted nodes should be drawn.
-	 */
-	JCheckBox drawDeleted = new JCheckBox("Draw deleted lines.");
 	/**
 	 * The checkbox stating whether nodes should be merged together.
@@ -203,6 +198,4 @@
 		forceRawGpsLines.setSelected(Main.pref.isForceRawGpsLines());
 		forceRawGpsLines.setEnabled(drawRawGpsLines.isSelected());
-		drawDeleted.setToolTipText("Draw dark hints where objects were deleted.");
-		drawDeleted.setSelected(Main.pref.isDrawDeleted());
 		mergeNodes.setToolTipText("When importing GPX data, all nodes with exact the same lat/lon are merged.");
 		mergeNodes.setSelected(Main.pref.mergeNodes);
@@ -219,5 +212,4 @@
 		display.add(drawRawGpsLines, GBC.eol().insets(20,0,0,0));
 		display.add(forceRawGpsLines, GBC.eol().insets(40,0,0,0));
-		display.add(drawDeleted, GBC.eol().insets(20,0,0,0));
 		display.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));
 
Index: /src/org/openstreetmap/josm/gui/SelectionManager.java
===================================================================
--- /src/org/openstreetmap/josm/gui/SelectionManager.java	(revision 29)
+++ /src/org/openstreetmap/josm/gui/SelectionManager.java	(revision 30)
@@ -278,5 +278,5 @@
 			
 			// pending line segments
-			for (LineSegment ls : Main.main.ds.pendingLineSegments)
+			for (LineSegment ls : Main.main.ds.lineSegments)
 				if (rectangleContainLineSegment(r, alt, ls))
 					selection.add(ls);
Index: /src/org/openstreetmap/josm/gui/dialogs/LayerList.java
===================================================================
--- /src/org/openstreetmap/josm/gui/dialogs/LayerList.java	(revision 29)
+++ /src/org/openstreetmap/josm/gui/dialogs/LayerList.java	(revision 30)
@@ -74,7 +74,6 @@
 	 */
 	public LayerList(MapFrame mapFrame) {
-		super(mapFrame, "Layers", "List of all layers", "layerlist", KeyEvent.VK_L, "Open a list of all loaded layers.");
-		setSize(250,256);
-		setMinimumSize(new Dimension(70,70));
+		super("Layers", "List of all layers", "layerlist", KeyEvent.VK_L, "Open a list of all loaded layers.");
+		setPreferredSize(new Dimension(320,100));
 		add(new JScrollPane(layers), BorderLayout.CENTER);
 		layers.setBackground(UIManager.getColor("Button.background"));
Index: /src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
===================================================================
--- /src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java	(revision 29)
+++ /src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java	(revision 30)
@@ -3,4 +3,5 @@
 import java.awt.BorderLayout;
 import java.awt.Component;
+import java.awt.Dimension;
 import java.awt.Font;
 import java.awt.GridLayout;
@@ -210,9 +211,8 @@
 	 */
 	public PropertiesDialog(MapFrame mapFrame) {
-		super(mapFrame, "Properties", "Properties Dialog", "properties", KeyEvent.VK_P, "Property for selected objects.");
+		super("Properties", "Properties Dialog", "properties", KeyEvent.VK_P, "Property for selected objects.");
 		mv = mapFrame.mapView;
 
-		setLayout(new BorderLayout());
-		setSize(350,450);
+		setPreferredSize(new Dimension(320,150));
 		
 		data.setColumnIdentifiers(new String[]{"Key", "Value"});
@@ -241,5 +241,5 @@
 		JScrollPane scrollPane = new JScrollPane(propertyTable);
 		scrollPane.addMouseListener(new DblClickWatch());
-		getContentPane().add(scrollPane, BorderLayout.CENTER);
+		add(scrollPane, BorderLayout.CENTER);
 		
 		JPanel buttonPanel = new JPanel(new GridLayout(1,3));
@@ -264,6 +264,6 @@
 		buttonPanel.add(createButton("Add", "Add a new key/value pair to all objects", KeyEvent.VK_A, buttonAction));
 		buttonPanel.add(createButton("Edit", "Edit the value of the selected key for all objects", KeyEvent.VK_E, buttonAction));
-		buttonPanel.add(createButton("Delete", "Delete the selected key in all objects", KeyEvent.VK_DELETE, buttonAction));
-		getContentPane().add(buttonPanel, BorderLayout.SOUTH);
+		buttonPanel.add(createButton("Delete", "Delete the selected key in all objects", KeyEvent.VK_D, buttonAction));
+		add(buttonPanel, BorderLayout.SOUTH);
 	}
 	
Index: /src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
===================================================================
--- /src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java	(revision 29)
+++ /src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java	(revision 30)
@@ -3,4 +3,5 @@
 import java.awt.BorderLayout;
 import java.awt.Component;
+import java.awt.Dimension;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
@@ -46,7 +47,6 @@
 	 */
 	public SelectionListDialog(MapFrame mapFrame) {
-		super(mapFrame, "Current Selection", "Selection List", "selectionlist", KeyEvent.VK_E, "Open a selection list window.");
-		setLayout(new BorderLayout());
-		setSize(300,400);
+		super("Current Selection", "Selection List", "selectionlist", KeyEvent.VK_E, "Open a selection list window.");
+		setPreferredSize(new Dimension(320,150));
 		displaylist.setCellRenderer(new DefaultListCellRenderer(){
 			private SelectionComponentVisitor visitor = new SelectionComponentVisitor();
@@ -64,5 +64,5 @@
 		displaylist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
 
-		getContentPane().add(new JScrollPane(displaylist), BorderLayout.CENTER);
+		add(new JScrollPane(displaylist), BorderLayout.CENTER);
 
 		JButton button = new JButton("Select", ImageProvider.get("mapmode", "selection"));
@@ -73,5 +73,5 @@
 			}
 		});
-		getContentPane().add(button, BorderLayout.SOUTH);
+		add(button, BorderLayout.SOUTH);
 
 		selectionChanged(Main.main.ds.getSelected());
Index: /src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
===================================================================
--- /src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java	(revision 29)
+++ /src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java	(revision 30)
@@ -1,7 +1,6 @@
 package org.openstreetmap.josm.gui.dialogs;
 
+import java.awt.BorderLayout;
 import java.awt.event.ActionEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
 import java.util.HashMap;
 import java.util.Map;
@@ -9,11 +8,9 @@
 import javax.swing.AbstractButton;
 import javax.swing.Action;
-import javax.swing.JComponent;
-import javax.swing.JDialog;
-import javax.swing.KeyStroke;
+import javax.swing.BorderFactory;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
 
-import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.gui.ImageProvider;
-import org.openstreetmap.josm.gui.MapFrame;
 
 /**
@@ -23,5 +20,5 @@
  * @author imi
  */
-public class ToggleDialog extends JDialog implements Action {
+public class ToggleDialog extends JPanel implements Action {
 
 	/**
@@ -29,20 +26,14 @@
 	 * @param title The title of the dialog.
 	 */
-	public ToggleDialog(MapFrame mapFrame, String title, String name, String iconName, int mnemonic, String tooltip) {
-		super(Main.main, title, false);
+	public ToggleDialog(String title, String name, String iconName, int mnemonic, String tooltip) {
 		putValue(SMALL_ICON, ImageProvider.get("dialogs", iconName));
 		putValue(NAME, name);
 		putValue(MNEMONIC_KEY, mnemonic);
-		KeyStroke ks = KeyStroke.getKeyStroke(mnemonic,0);
-		putValue(ACCELERATOR_KEY, ks);
-		mapFrame.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ks, this);
-		mapFrame.getActionMap().put(this, this);
-		putValue(LONG_DESCRIPTION, tooltip);
-		mapFrame.addPropertyChangeListener("visible", new PropertyChangeListener(){
-			public void propertyChange(PropertyChangeEvent evt) {
-				if (evt.getNewValue() == Boolean.FALSE)
-					setVisible(false);
-			}
-		});
+		putValue(SHORT_DESCRIPTION, tooltip);
+		
+		setLayout(new BorderLayout());
+		add(new JLabel(title), BorderLayout.NORTH);
+		setVisible(false);
+		setBorder(BorderFactory.createEtchedBorder());
 	}
 
Index: c/org/openstreetmap/josm/gui/layer/EditLayer.java
===================================================================
--- /src/org/openstreetmap/josm/gui/layer/EditLayer.java	(revision 29)
+++ 	(revision )
@@ -1,197 +1,0 @@
-package org.openstreetmap.josm.gui.layer;
-
-import java.awt.Color;
-import java.awt.Graphics;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedList;
-
-import javax.swing.Icon;
-import javax.swing.SwingUtilities;
-
-import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.command.Command;
-import org.openstreetmap.josm.data.Bounds;
-import org.openstreetmap.josm.data.osm.Node;
-import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor;
-import org.openstreetmap.josm.data.osm.visitor.BoundingVisitor;
-import org.openstreetmap.josm.data.osm.visitor.SimplePaintVisitor;
-import org.openstreetmap.josm.data.projection.Projection;
-import org.openstreetmap.josm.gui.ImageProvider;
-import org.openstreetmap.josm.gui.MapView;
-import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
-
-/**
- * The layer that contain all editing commands in the current session. All commands
- * are saved here. The command actions "move" data from the data layer to this 
- * layer (by just removing them from the data layer) for all edited data, so 
- * invisible this layer will actually invisible all changes made to the data set.
- * 
- * There may only be one EditLayer per MapView.
- * 
- * Only EditLayers can be uploaded to the server.
- */
-public class EditLayer extends Layer implements LayerChangeListener, PropertyChangeListener {
-
-	private static Icon icon;
-
-	/**
-	 * All commands that were made on the dataset.
-	 */
-	public LinkedList<Command> commands = new LinkedList<Command>();
-
-	/**
-	 * The map view this layer belongs to.
-	 */
-	private final MapView mv;
-
-	/**
-	 * Create an initial empty edit layer.
-	 * @param mv The mapview that emits layer change events.
-	 */
-	public EditLayer(final MapView mv) {
-		super("not uploaded changes");
-		this.mv = mv;
-		mv.addLayerChangeListener(this);
-		Main.pref.addPropertyChangeListener(this);
-	}
-
-
-	/**
-	 * Paint all changes in the changes list.
-	 * @param g
-	 * @param mv
-	 */
-	@Override
-	public void paint(Graphics g, MapView mv) {
-		LinkedList<OsmPrimitive> changes = new LinkedList<OsmPrimitive>();
-		LinkedList<OsmPrimitive> deleted = new LinkedList<OsmPrimitive>();
-		for (Command c : commands)
-			c.fillModifiedData(changes, deleted, changes);
-
-		SimplePaintVisitor visitor = new SimplePaintVisitor(g, mv, null);
-		SimplePaintVisitor deletedvisitor = new SimplePaintVisitor(g, mv, Color.DARK_GRAY);
-
-		changes.removeAll(deleted);
-
-		// first draw deleted objects in dark gray
-		if (Main.pref.isDrawDeleted())
-			for (OsmPrimitive osm : deleted)
-				osm.visit(deletedvisitor);
-		// next draw the tracks (and line segments)
-		for (OsmPrimitive osm : changes)
-			if (!(osm instanceof Node))
-				osm.visit(visitor);
-		// now draw the remaining objects
-		for (OsmPrimitive osm : changes)
-			if (osm instanceof Node)
-				osm.visit(visitor);
-		
-	}
-
-	@Override
-	public Icon getIcon() {
-		if (icon == null)
-			icon = ImageProvider.get("layer", "edit");
-		return icon;
-	}
-
-	@Override
-	public String getToolTipText() {
-		return commands.size()+" changes";
-	}
-
-	@Override
-	public void mergeFrom(Layer from) {
-		EditLayer edit = (EditLayer)from;
-		commands.addAll(edit.commands);
-	}
-
-	@Override
-	public boolean isMergable(Layer other) {
-		return other instanceof EditLayer;
-	}
-
-	@Override
-	public Bounds getBoundsLatLon() {
-		LinkedList<OsmPrimitive> data = new LinkedList<OsmPrimitive>();
-		for (Command c : commands)
-			c.fillModifiedData(data, null, data); // all in one list
-		BoundingVisitor b = new BoundingVisitor(BoundingVisitor.Type.LATLON);
-		for (OsmPrimitive osm : data)
-			osm.visit(b);
-		return b.bounds;
-	}
-
-	@Override
-	public Bounds getBoundsXY() {
-		LinkedList<OsmPrimitive> data = new LinkedList<OsmPrimitive>();
-		for (Command c : commands)
-			c.fillModifiedData(data, null, data); // all in one list
-		BoundingVisitor b = new BoundingVisitor(BoundingVisitor.Type.XY);
-		for (OsmPrimitive osm : data)
-			osm.visit(b);
-		return b.bounds;
-	}
-
-	@Override
-	public void init(Projection projection) {
-		LinkedList<OsmPrimitive> data = new LinkedList<OsmPrimitive>();
-		for (Command c : commands)
-			c.fillModifiedData(data, data, data); // all in one list
-		for (OsmPrimitive osm : data)
-			for (Node n : AllNodesVisitor.getAllNodes(osm))
-				projection.latlon2xy(n.coor);
-	}
-	
-	/**
-	 * Execute the command and add it to the intern command queue. Also mark all
-	 * primitives in the command as modified.
-	 */
-	public void add(Command c) {
-		c.executeCommand();
-		Collection<OsmPrimitive> data = new HashSet<OsmPrimitive>();
-		c.fillModifiedData(data, data, data);
-		for (OsmPrimitive osm : data)
-			osm.modified = true;
-		commands.add(c);
-	}
-
-	/**
-	 * Clean up the data and remove itself from the map view after
-	 * the notifications ended.
-	 */
-	public void layerRemoved(Layer oldLayer) {
-		if (oldLayer == EditLayer.this) {
-			Collection<OsmPrimitive> data = new HashSet<OsmPrimitive>();
-			for (Command c : commands)
-				c.fillModifiedData(data, data, data);
-			for (OsmPrimitive osm : data)
-				osm.modified = false;
-			commands.clear();
-			SwingUtilities.invokeLater(new Runnable(){
-				public void run() {
-					mv.removeLayerChangeListener(EditLayer.this);
-				}
-			});
-		}
-	}
-	
-	/**
-	 * Does nothing. Only to satisfy LayerChangeListener
-	 */
-	public void activeLayerChange(Layer oldLayer, Layer newLayer) {}
-	/**
-	 * Does nothing. Only to satisfy LayerChangeListener
-	 */
-	public void layerAdded(Layer newLayer) {}
-
-
-	public void propertyChange(PropertyChangeEvent evt) {
-		if (evt.getPropertyName().equals("drawDeleted"))
-			mv.repaint();
-	}
-}
Index: /src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
===================================================================
--- /src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java	(revision 29)
+++ /src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java	(revision 30)
@@ -2,13 +2,19 @@
 
 import java.awt.Graphics;
-import java.util.Collection;
+import java.io.FileWriter;
+import java.io.StringWriter;
+import java.util.LinkedList;
 
 import javax.swing.Icon;
 
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.command.Command;
 import org.openstreetmap.josm.data.Bounds;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.osm.LineSegment;
 import org.openstreetmap.josm.data.osm.Node;
-import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor;
+import org.openstreetmap.josm.data.osm.Track;
 import org.openstreetmap.josm.data.osm.visitor.BoundingVisitor;
+import org.openstreetmap.josm.data.osm.visitor.CsvVisitor;
 import org.openstreetmap.josm.data.osm.visitor.SimplePaintVisitor;
 import org.openstreetmap.josm.data.projection.Projection;
@@ -17,6 +23,5 @@
 
 /**
- * A layer holding data imported from the osm server.
- * 
+ * A layer holding data from a specific dataset.
  * The data can be fully edited.
  * 
@@ -28,12 +33,18 @@
 
 	/**
-	 * The data behind this layer. A list of primitives which are also in Main.main.ds.
+	 * The data behind this layer.
 	 */
-	private final Collection<OsmPrimitive> data;
+	public final DataSet data;
+
+	/**
+	 * All commands that were made on the dataset.
+	 */
+	private LinkedList<Command> commands = new LinkedList<Command>();
+	private LinkedList<String> debugDsBefore = new LinkedList<String>();
 
 	/**
 	 * Construct a OsmDataLayer.
 	 */
-	public OsmDataLayer(Collection<OsmPrimitive> data, String name) {
+	public OsmDataLayer(DataSet data, String name) {
 		super(name);
 		this.data = data;
@@ -59,22 +70,21 @@
 	public void paint(Graphics g, MapView mv) {
 		SimplePaintVisitor visitor = new SimplePaintVisitor(g, mv, null);
-		// first draw the tracks (and line segments)
-		for (OsmPrimitive osm : data)
-			if (!osm.modified && !(osm instanceof Node))
-				osm.visit(visitor);
-		for (OsmPrimitive osm : data)
-			if (!osm.modified && osm instanceof Node)
-				osm.visit(visitor);
+
+		for (Track t : data.tracks)
+			visitor.visit(t);
+		for (LineSegment ls : data.lineSegments)
+			visitor.visit(ls);
+		for (Node n : data.nodes)
+			visitor.visit(n);
 	}
 
 	@Override
 	public String getToolTipText() {
-		return data.size()+" primitives.";
+		return data.nodes.size()+" nodes, "+data.tracks.size()+" streets.";
 	}
 
 	@Override
 	public void mergeFrom(Layer from) {
-		OsmDataLayer layer = (OsmDataLayer)from;
-		data.addAll(layer.data);
+		data.mergeFrom(((OsmDataLayer)from).data);
 	}
 
@@ -87,6 +97,6 @@
 	public Bounds getBoundsLatLon() {
 		BoundingVisitor b = new BoundingVisitor(BoundingVisitor.Type.LATLON);
-		for (OsmPrimitive osm : data)
-			osm.visit(b);
+		for (Node n : data.nodes)
+			b.visit(n);
 		return b.bounds;
 	}
@@ -95,6 +105,6 @@
 	public Bounds getBoundsXY() {
 		BoundingVisitor b = new BoundingVisitor(BoundingVisitor.Type.XY);
-		for (OsmPrimitive osm : data)
-			osm.visit(b);
+		for (Node n : data.nodes)
+			b.visit(n);
 		return b.bounds;
 	}
@@ -102,7 +112,70 @@
 	@Override
 	public void init(Projection projection) {
-		for (OsmPrimitive osm : data)
-			for (Node n : AllNodesVisitor.getAllNodes(osm))
-				projection.latlon2xy(n.coor);
+		for (Node n : data.nodes)
+			projection.latlon2xy(n.coor);
+	}
+
+	/**
+	 * Execute the command and add it to the intern command queue. Also mark all
+	 * primitives in the command as modified.
+	 */
+	public void add(Command c) {
+		StringWriter sw = new StringWriter();
+		CsvVisitor v = new CsvVisitor(sw);
+		for (Node n : Main.main.ds.nodes) {
+			v.visit(n);
+			sw.append('\n');
+		}
+		for (LineSegment ls : Main.main.ds.lineSegments) {
+			v.visit(ls);
+			sw.append('\n');
+		}
+		for (Track t : Main.main.ds.tracks) {
+			v.visit(t);
+			sw.append('\n');
+		}
+		debugDsBefore.add(sw.getBuffer().toString());
+		
+		c.executeCommand();
+		commands.add(c);
+	}
+
+	/**
+	 * Undoes the last added command.
+	 */
+	public void undo() {
+		if (commands.isEmpty())
+			return;
+		Command c = commands.removeLast();
+		c.undoCommand();
+		
+		//DEBUG
+		StringWriter sw = new StringWriter();
+		CsvVisitor v = new CsvVisitor(sw);
+		for (Node n : Main.main.ds.nodes) {
+			v.visit(n);
+			sw.append('\n');
+		}
+		for (LineSegment ls : Main.main.ds.lineSegments) {
+			v.visit(ls);
+			sw.append('\n');
+		}
+		for (Track t : Main.main.ds.tracks) {
+			v.visit(t);
+			sw.append('\n');
+		}
+		String s = Main.main.getMapFrame().mapView.editLayer().debugDsBefore.removeLast();
+		if (!s.equals(sw.getBuffer().toString())) {
+			try {
+				FileWriter fw = new FileWriter("/home/imi/richtig");
+				fw.append(sw.getBuffer().toString());
+				fw.close();
+				fw = new FileWriter("/home/imi/falsch");
+				fw.append(s);
+				fw.close();
+			} catch (Exception x) {
+				x.printStackTrace();
+			}
+		}
 	}
 }
Index: /src/org/openstreetmap/josm/io/GpxReader.java
===================================================================
--- /src/org/openstreetmap/josm/io/GpxReader.java	(revision 29)
+++ /src/org/openstreetmap/josm/io/GpxReader.java	(revision 30)
@@ -115,5 +115,5 @@
 	private void parseTrack(Element e, DataSet ds) {
 		Track track = new Track();
-		boolean pendingLS = false; // is this track just a fake?
+		boolean realLineSegment = false; // is this track just a fake?
 
 		for (Object o : e.getChildren()) {
@@ -137,5 +137,5 @@
 				parseKeyValueExtensions(track, child);
 				if (child.getChild("segment", OSM) != null)
-					pendingLS = true;
+					realLineSegment = true;
 			} else if (child.getName().equals("link"))
 				parseKeyValueLink(track, child);
@@ -143,8 +143,10 @@
 				parseKeyValueTag(track, child);
 		}
-		if (pendingLS && track.segments.size() == 1)
-			ds.pendingLineSegments.add(track.segments.get(0));
-		else
+		if (realLineSegment && track.segments.size() == 1)
+			ds.lineSegments.add(track.segments.get(0));
+		else {
 			ds.tracks.add(track);
+			ds.lineSegments.addAll(track.segments);
+		}
 	}
 	
Index: /src/org/openstreetmap/josm/io/GpxWriter.java
===================================================================
--- /src/org/openstreetmap/josm/io/GpxWriter.java	(revision 29)
+++ /src/org/openstreetmap/josm/io/GpxWriter.java	(revision 30)
@@ -109,5 +109,5 @@
 		
 		// encode pending line segments as tracks
-		for (LineSegment ls : Main.main.ds.pendingLineSegments) {
+		for (LineSegment ls : Main.main.ds.lineSegments) {
 			Element t = new Element("trk", GPX);
 			t.getChildren().add(parseLineSegment(ls));
Index: /src/org/openstreetmap/josm/io/OsmReader.java
===================================================================
--- /src/org/openstreetmap/josm/io/OsmReader.java	(revision 29)
+++ /src/org/openstreetmap/josm/io/OsmReader.java	(revision 30)
@@ -118,10 +118,10 @@
 			else if (child.getName().equals("segment")) {
 				LineSegment ls = parseLineSegment(child, data);
-				if (data.pendingLineSegments.contains(ls))
+				if (data.lineSegments.contains(ls))
 					throw new JDOMException("Double segment definition "+ls.id);
 				for (Track t : data.tracks)
 					if (t.segments.contains(ls))
 						throw new JDOMException("Double segment definition "+ls.id);
-				data.pendingLineSegments.add(ls);
+				data.lineSegments.add(ls);
 			} else if (child.getName().equals("track")) {
 				Track track = parseTrack(child, data);
@@ -175,8 +175,8 @@
 			Element child = (Element)o;
 			long id = Long.parseLong(child.getAttributeValue("uid"));
-			LineSegment ls = findLineSegment(data.pendingLineSegments, id);
+			LineSegment ls = findLineSegment(data.lineSegments, id);
 			if (ls != null) {
 				track.segments.add(ls);
-				data.pendingLineSegments.remove(ls);
+				data.lineSegments.remove(ls);
 				continue;
 			}
Index: /src/org/openstreetmap/josm/io/OsmWriter.java
===================================================================
--- /src/org/openstreetmap/josm/io/OsmWriter.java	(revision 29)
+++ /src/org/openstreetmap/josm/io/OsmWriter.java	(revision 30)
@@ -62,5 +62,5 @@
 		for (Node n : ds.nodes)
 			list.add(parseNode(n, properties));
-		for (LineSegment ls : ds.pendingLineSegments)
+		for (LineSegment ls : ds.lineSegments)
 			list.add(parseLineSegment(ls, properties));
 		// all other line segments
@@ -159,5 +159,5 @@
 		for (OsmPrimitive osm : ds.nodes)
 			addIdAndKeyIds(osm, ids);
-		for (OsmPrimitive osm : ds.pendingLineSegments)
+		for (OsmPrimitive osm : ds.lineSegments)
 			addIdAndKeyIds(osm, ids);
 		for (Track t : ds.tracks) {
