Index: src/org/openstreetmap/josm/Main.java
===================================================================
--- src/org/openstreetmap/josm/Main.java	(revision 76)
+++ src/org/openstreetmap/josm/Main.java	(revision 77)
@@ -227,5 +227,4 @@
 			if (arguments.remove("--reset-preferences")) {
 				pref.resetToDefault();
-				pref.save();
 			} else
 				pref.load();
@@ -234,10 +233,4 @@
 			errMsg = "Preferences could not be loaded. Write default preference file to '"+Preferences.getPreferencesDir()+"preferences'.";
 			pref.resetToDefault();
-			try {
-				pref.save();
-			} catch (IOException e) {
-				e.printStackTrace();
-				errMsg = "Preferences could not be loaded. Reverting to default.";
-			}
 		}
 		if (errMsg != null)
Index: src/org/openstreetmap/josm/actions/DownloadAction.java
===================================================================
--- src/org/openstreetmap/josm/actions/DownloadAction.java	(revision 76)
+++ src/org/openstreetmap/josm/actions/DownloadAction.java	(revision 77)
@@ -89,10 +89,4 @@
 			int cutPos = osmDataServer.endsWith("/0.2") ? 4 : 5;
 			Main.pref.put("osm-server.url", osmDataServer.substring(0, osmDataServer.length()-cutPos));
-			try {
-				Main.pref.save();
-			} catch (IOException x) {
-				x.printStackTrace();
-				JOptionPane.showMessageDialog(Main.main, "Could not save the preferences change:\n" + x.getMessage());
-			}
 		}
 
Index: src/org/openstreetmap/josm/actions/UploadAction.java
===================================================================
--- src/org/openstreetmap/josm/actions/UploadAction.java	(revision 76)
+++ src/org/openstreetmap/josm/actions/UploadAction.java	(revision 77)
@@ -5,5 +5,4 @@
 import java.awt.event.InputEvent;
 import java.awt.event.KeyEvent;
-import java.io.IOException;
 import java.util.Collection;
 import java.util.LinkedList;
@@ -54,10 +53,4 @@
 			int cutPos = osmDataServer.endsWith("/0.2") ? 4 : 5;
 			Main.pref.put("osm-server.url", osmDataServer.substring(0, osmDataServer.length()-cutPos));
-			try {
-				Main.pref.save();
-			} catch (IOException x) {
-				x.printStackTrace();
-				JOptionPane.showMessageDialog(Main.main, "Could not save the preferences change:\n" + x.getMessage());
-			}
 		}
 
Index: src/org/openstreetmap/josm/data/Preferences.java
===================================================================
--- src/org/openstreetmap/josm/data/Preferences.java	(revision 76)
+++ src/org/openstreetmap/josm/data/Preferences.java	(revision 77)
@@ -8,6 +8,5 @@
 import java.io.PrintWriter;
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedList;
+import java.util.Map;
 import java.util.SortedMap;
 import java.util.TreeMap;
@@ -66,9 +65,9 @@
 		return prop;
 	}
-	synchronized public Collection<Entry<String, String>> getAllPrefix(String prefix) {
-		LinkedList<Entry<String,String>> all = new LinkedList<Entry<String,String>>();
+	synchronized public Map<String, String> getAllPrefix(String prefix) {
+		Map<String,String> all = new TreeMap<String,String>();
 		for (Entry<String,String> e : properties.entrySet())
 			if (e.getKey().startsWith(prefix))
-				all.add(e);
+				all.put(e.getKey(), e.getValue());
 		return all;
 	}
@@ -80,10 +79,13 @@
 	synchronized public void put(String key, String value) {
 		if (value == null)
-			value = "";
-		properties.put(key, value);
+			properties.remove(key);
+		else
+			properties.put(key, value);
+		save();
 		firePreferenceChanged(key, value);
 	}
 	synchronized public void put(String key, boolean value) {
 		properties.put(key, Boolean.toString(value));
+		save();
 		firePreferenceChanged(key, Boolean.toString(value));
 	}
@@ -95,10 +97,21 @@
 
 
-	public void save() throws IOException {
-		PrintWriter out = new PrintWriter(new FileWriter(getPreferencesDir()+"preferences"));
-		for (Entry<String, String> e : properties.entrySet())
-			if (!e.getValue().equals(""))
-				out.println(e.getKey()+"="+e.getValue());
-		out.close();
+	/**
+	 * Called after every put. In case of a problem, do nothing but output the error
+	 * in log.
+	 */
+	private void save() {
+		try {
+			PrintWriter out = new PrintWriter(new FileWriter(
+					getPreferencesDir() + "preferences"));
+			for (Entry<String, String> e : properties.entrySet())
+				if (!e.getValue().equals(""))
+					out.println(e.getKey() + "=" + e.getValue());
+			out.close();
+		} catch (IOException e) {
+			e.printStackTrace();
+			// do not message anything, since this can be called from strange
+			// places.
+		}		
 	}
 
@@ -127,4 +140,5 @@
 		properties.put("color.selected", ColorHelper.color2html(Color.white));
 		properties.put("color.gps point", ColorHelper.color2html(Color.gray));
+		save();
 	}
 }
Index: src/org/openstreetmap/josm/gui/MapView.java
===================================================================
--- src/org/openstreetmap/josm/gui/MapView.java	(revision 76)
+++ src/org/openstreetmap/josm/gui/MapView.java	(revision 77)
@@ -11,7 +11,4 @@
 import java.util.LinkedList;
 
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.Bounds;
@@ -20,5 +17,4 @@
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
-import org.openstreetmap.josm.data.projection.Projection;
 import org.openstreetmap.josm.gui.layer.Layer;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
@@ -38,5 +34,5 @@
  * @author imi
  */
-public class MapView extends NavigatableComponent implements ChangeListener {
+public class MapView extends NavigatableComponent {
 
 	/**
@@ -92,7 +88,4 @@
 	 */
 	public void addLayer(Layer layer) {
-		// reinitialize layer's data
-		layer.init(getProjection());
-
 		if (layer instanceof OsmDataLayer) {
 			final OsmDataLayer dataLayer = (OsmDataLayer)layer;
@@ -322,14 +315,3 @@
 			firePropertyChange("scale", oldScale, scale);
 	}
-
-	/**
-	 * Notify from the projection, that something has changed.
-	 */
-	public void stateChanged(ChangeEvent e) {
-		// reset all datasets.
-		Projection p = getProjection();
-		for (Layer l : layers)
-			l.init(p);
-		recalculateCenterScale();
-	}
 }
Index: src/org/openstreetmap/josm/gui/PreferenceDialog.java
===================================================================
--- src/org/openstreetmap/josm/gui/PreferenceDialog.java	(revision 76)
+++ src/org/openstreetmap/josm/gui/PreferenceDialog.java	(revision 77)
@@ -8,6 +8,6 @@
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.io.IOException;
-import java.util.Collection;
+import java.util.Map;
+import java.util.TreeMap;
 import java.util.Vector;
 import java.util.Map.Entry;
@@ -78,10 +78,4 @@
 			}
 
-			try {
-				Main.pref.save();
-			} catch (IOException x) {
-				x.printStackTrace();
-				JOptionPane.showMessageDialog(PreferenceDialog.this, "Could not save preferences:\n"+x.getMessage());
-			}
 			if (requiresRestart)
 				JOptionPane.showMessageDialog(PreferenceDialog.this, "You have to restart JOSM for some settings to take effect.");
@@ -212,7 +206,9 @@
 
 		
-		Collection<Entry<String,String>> c = Main.pref.getAllPrefix("color.");
+		
+		Map<String,String> allColors = new TreeMap<String, String>(Main.pref.getAllPrefix("color."));
+
 		Vector<Vector<Object>> rows = new Vector<Vector<Object>>();
-		for (Entry<String,String> e : c) {
+		for (Entry<String,String> e : allColors.entrySet()) {
 			Vector<Object> row = new Vector<Object>(2);
 			row.add(e.getKey().substring("color.".length()));
@@ -229,4 +225,18 @@
 		};
 		colors.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+		final TableCellRenderer oldColorsRenderer = colors.getDefaultRenderer(Object.class);
+		colors.setDefaultRenderer(Object.class, new TableCellRenderer(){
+			public Component getTableCellRendererComponent(JTable t, Object o, boolean selected, boolean focus, int row, int column) {
+				if (column == 1) {
+					JLabel l = new JLabel(ColorHelper.color2html((Color)o));
+					l.setBackground((Color)o);
+					l.setOpaque(true);
+					return l;
+				}
+				return oldColorsRenderer.getTableCellRendererComponent(t,o,selected,focus,row,column);
+			}
+		});
+		colors.getColumnModel().getColumn(1).setWidth(100);
+		
 		JButton colorEdit = new JButton("Choose");
 		colorEdit.addActionListener(new ActionListener(){
@@ -243,17 +253,4 @@
 			}
 		});
-		final TableCellRenderer oldColorsRenderer = colors.getDefaultRenderer(Object.class);
-		colors.setDefaultRenderer(Object.class, new TableCellRenderer(){
-			public Component getTableCellRendererComponent(JTable t, Object o, boolean selected, boolean focus, int row, int column) {
-				if (column == 1) {
-					JLabel l = new JLabel(ColorHelper.color2html((Color)o));
-					l.setBackground((Color)o);
-					l.setOpaque(true);
-					return l;
-				}
-				return oldColorsRenderer.getTableCellRendererComponent(t,o,selected,focus,row,column);
-			}
-		});
-		colors.getColumnModel().getColumn(1).setWidth(100);
 
 		// setting tooltips
Index: src/org/openstreetmap/josm/gui/dialogs/LayerList.java
===================================================================
--- src/org/openstreetmap/josm/gui/dialogs/LayerList.java	(revision 76)
+++ src/org/openstreetmap/josm/gui/dialogs/LayerList.java	(revision 77)
@@ -2,4 +2,5 @@
 
 import java.awt.BorderLayout;
+import java.awt.Color;
 import java.awt.Component;
 import java.awt.Dimension;
@@ -8,4 +9,6 @@
 import java.awt.event.ActionListener;
 import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
 import java.util.Collection;
 
@@ -14,7 +17,11 @@
 import javax.swing.Icon;
 import javax.swing.JButton;
+import javax.swing.JColorChooser;
 import javax.swing.JLabel;
 import javax.swing.JList;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
 import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
 import javax.swing.JScrollPane;
 import javax.swing.ListSelectionModel;
@@ -29,4 +36,6 @@
 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
 import org.openstreetmap.josm.gui.layer.Layer;
+import org.openstreetmap.josm.gui.layer.RawGpsDataLayer;
+import org.openstreetmap.josm.tools.ColorHelper;
 import org.openstreetmap.josm.tools.ImageProvider;
 import org.openstreetmap.josm.tools.ImageProvider.OverlayPosition;
@@ -111,4 +120,45 @@
 		mapView.addLayerChangeListener(this);
 
+		layers.addMouseListener(new MouseAdapter(){
+			private void openPopup(MouseEvent e) {
+				final int index = layers.locationToIndex(e.getPoint());
+				final Layer layer = (Layer)layers.getModel().getElementAt(index);
+				if (!(layer instanceof RawGpsDataLayer))
+					return; // currently only options for raw layers.
+				JPopupMenu menu = new JPopupMenu();
+				JMenuItem color = new JMenuItem("Customize Color");
+				color.addActionListener(new ActionListener(){
+					public void actionPerformed(ActionEvent e) {
+						String col = Main.pref.get("color.layer "+layer.name, Main.pref.get("color.gps point", ColorHelper.color2html(Color.gray)));
+						JColorChooser c = new JColorChooser(ColorHelper.html2color(col));
+						Object[] options = new Object[]{"OK", "Cancel", "Default"};
+						int answer = JOptionPane.showOptionDialog(Main.main, c, "Choose a color", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
+						switch (answer) {
+						case 0:
+							Main.pref.put("color.layer "+layer.name, ColorHelper.color2html(c.getColor()));
+							break;
+						case 1:
+							return;
+						case 2:
+							Main.pref.put("color.layer "+layer.name, null);
+							break;
+						}
+						Main.main.repaint();
+					}
+				});
+				menu.add(color);
+				menu.show(LayerList.this, e.getX(), e.getY());
+			}
+			@Override public void mousePressed(MouseEvent e) {
+				if (e.isPopupTrigger())
+					openPopup(e);
+			}
+			@Override public void mouseReleased(MouseEvent e) {
+				if (e.isPopupTrigger())
+					openPopup(e);
+			}
+		});
+		
+		
 		// Buttons
 		JPanel buttonPanel = new JPanel(new GridLayout(1, 5));
@@ -222,3 +272,5 @@
 		updateButtonEnabled();
 	}
+
+	public void layerMoved(Layer layer, int newPosition) {}
 }
Index: src/org/openstreetmap/josm/gui/layer/Layer.java
===================================================================
--- src/org/openstreetmap/josm/gui/layer/Layer.java	(revision 76)
+++ src/org/openstreetmap/josm/gui/layer/Layer.java	(revision 77)
@@ -6,5 +6,4 @@
 
 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
-import org.openstreetmap.josm.data.projection.Projection;
 import org.openstreetmap.josm.gui.MapView;
 
@@ -79,8 +78,3 @@
 	 */
 	abstract public void visitBoundingBox(BoundingXYVisitor v);
-
-	/**
-	 * Initialize the internal dataset with the given projection.
-	 */
-	abstract public void init(Projection projection);
 }
Index: src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
===================================================================
--- src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java	(revision 76)
+++ src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java	(revision 77)
@@ -21,5 +21,4 @@
 import org.openstreetmap.josm.data.osm.visitor.MergeVisitor;
 import org.openstreetmap.josm.data.osm.visitor.SimplePaintVisitor;
-import org.openstreetmap.josm.data.projection.Projection;
 import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.tools.ImageProvider;
@@ -138,10 +137,4 @@
 		for (Node n : data.nodes)
 			v.visit(n);
-	}
-
-	@Override
-	public void init(Projection projection) {
-		for (Node n : data.nodes)
-			projection.latlon2eastNorth(n.coor);
 	}
 
Index: src/org/openstreetmap/josm/gui/layer/RawGpsDataLayer.java
===================================================================
--- src/org/openstreetmap/josm/gui/layer/RawGpsDataLayer.java	(revision 76)
+++ src/org/openstreetmap/josm/gui/layer/RawGpsDataLayer.java	(revision 77)
@@ -14,5 +14,4 @@
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
-import org.openstreetmap.josm.data.projection.Projection;
 import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.tools.ColorHelper;
@@ -28,5 +27,5 @@
 
 	private static Icon icon;
-
+	
 	/**
 	 * A list of ways which containing a list of points.
@@ -38,12 +37,16 @@
 		super(name);
 		this.data = data;
-		
+
+		eastNorth = new LinkedList<Collection<EastNorth>>();
+		for (Collection<LatLon> c : data) {
+			Collection<EastNorth> eastNorthList = new LinkedList<EastNorth>();
+			for (LatLon ll : c)
+				eastNorthList.add(Main.proj.latlon2eastNorth(ll));
+			this.eastNorth.add(eastNorthList);
+		}
+
 		Main.pref.addPreferenceChangedListener(new PreferenceChangedListener(){
 			public void preferenceChanged(String key, String newValue) {
-				if (Main.main.getMapFrame() == null) {
-					Main.pref.removePreferenceChangedListener(this);
-					return;
-				}
-				if (key.equals("drawRawGpsLines") || key.equals("forceRawGpsLines"))
+				if (Main.main.getMapFrame() != null && (key.equals("drawRawGpsLines") || key.equals("forceRawGpsLines")))
 					Main.main.getMapFrame().repaint();
 			}
@@ -64,8 +67,11 @@
 	public void paint(Graphics g, MapView mv) {
 		String gpsCol = Main.pref.get("color.gps point");
-		if (gpsCol.equals(""))
+		String gpsColSpecial = Main.pref.get("color.layer "+name);
+		if (!gpsColSpecial.equals(""))
+			g.setColor(ColorHelper.html2color(gpsColSpecial));
+		else if (!gpsCol.equals(""))
+			g.setColor(ColorHelper.html2color(gpsCol));
+		else
 			g.setColor(Color.GRAY);
-		else
-			g.setColor(ColorHelper.html2color(gpsCol));
 		Point old = null;
 		for (Collection<EastNorth> c : eastNorth) {
@@ -108,14 +114,3 @@
 				v.visit(eastNorth);
 	}
-
-	@Override
-	public void init(Projection projection) {
-		eastNorth = new LinkedList<Collection<EastNorth>>();
-		for (Collection<LatLon> c : data) {
-			Collection<EastNorth> eastNorthList = new LinkedList<EastNorth>();
-			for (LatLon ll : c)
-				eastNorthList.add(Main.proj.latlon2eastNorth(ll));
-			this.eastNorth.add(eastNorthList);
-		}
-	}
 }
