Index: src/org/openstreetmap/josm/Main.java
===================================================================
--- src/org/openstreetmap/josm/Main.java	(revision 73)
+++ src/org/openstreetmap/josm/Main.java	(revision 74)
@@ -9,4 +9,5 @@
 import java.awt.event.WindowEvent;
 import java.io.File;
+import java.io.IOException;
 import java.util.Arrays;
 import java.util.Iterator;
@@ -33,5 +34,4 @@
 import org.openstreetmap.josm.actions.UploadAction;
 import org.openstreetmap.josm.data.Preferences;
-import org.openstreetmap.josm.data.Preferences.PreferencesException;
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.projection.Projection;
@@ -186,6 +186,4 @@
 		});
 		setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
-		
-		proj = pref.getProjection();
 	}
 
@@ -219,14 +217,34 @@
 		String errMsg = null;
 		try {
-			if (arguments.remove("--reset-preferences"))
+			if (arguments.remove("--reset-preferences")) {
+				pref.resetToDefault();
 				pref.save();
-			else
+			} else
 				pref.load();
-		} catch (PreferencesException e1) {
+		} catch (RuntimeException x) {
+			//TODO: Temporary code to update user preferences.
+			if (x.getMessage().equals("old version")) {
+				int answer = JOptionPane.showConfirmDialog(
+						null, 
+						"The preferences - file format has changed.\nThe settings will be reset to default.",
+						"Information",
+						JOptionPane.OK_CANCEL_OPTION);
+				if (answer == JOptionPane.CANCEL_OPTION)
+					System.exit(0);
+				pref.resetToDefault();
+				try {
+					pref.save();
+				} catch (IOException e) {
+					e.printStackTrace();
+					errMsg = "Preferences could not be loaded. Reverting to default.";
+				}
+			}
+		} catch (IOException e1) {
 			e1.printStackTrace();
 			errMsg = "Preferences could not be loaded. Write default preference file to '"+Preferences.getPreferencesDir()+"preferences'.";
+			pref.resetToDefault();
 			try {
 				pref.save();
-			} catch (PreferencesException e) {
+			} catch (IOException e) {
 				e.printStackTrace();
 				errMsg = "Preferences could not be loaded. Reverting to default.";
@@ -235,7 +253,15 @@
 		if (errMsg != null)
 			JOptionPane.showMessageDialog(null, errMsg);
-		
+
 		try {
-			UIManager.setLookAndFeel(pref.laf.getClassName());
+			proj = (Projection)Class.forName(pref.get("projection")).newInstance();
+		} catch (Exception e) {
+			e.printStackTrace();
+			JOptionPane.showMessageDialog(null, "The projection could not be initialized. Aborting.");
+			System.exit(1);
+		}
+		
+		try {
+			UIManager.setLookAndFeel(pref.get("laf"));
 		} catch (Exception e) {
 			e.printStackTrace();
Index: src/org/openstreetmap/josm/actions/DownloadAction.java
===================================================================
--- src/org/openstreetmap/josm/actions/DownloadAction.java	(revision 73)
+++ src/org/openstreetmap/josm/actions/DownloadAction.java	(revision 74)
@@ -31,5 +31,4 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.Bounds;
-import org.openstreetmap.josm.data.Preferences.PreferencesException;
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.DataSet;
@@ -78,6 +77,7 @@
 	public void actionPerformed(ActionEvent e) {
 		
+		String osmDataServer = Main.pref.get("osmDataServer");
 		//TODO: Remove this in later versions (temporary only)
-		if (Main.pref.osmDataServer.endsWith("/0.2") || Main.pref.osmDataServer.endsWith("/0.2/")) {
+		if (osmDataServer.endsWith("/0.2") || osmDataServer.endsWith("/0.2/")) {
 			int answer = JOptionPane.showConfirmDialog(Main.main, 
 					"You seem to have an outdated server entry in your preferences.\n" +
@@ -89,12 +89,11 @@
 			if (answer != JOptionPane.YES_OPTION)
 				return;
-			int cutPos = Main.pref.osmDataServer.endsWith("/0.2") ? 4 : 5;
-			Main.pref.osmDataServer = Main.pref.osmDataServer.substring(0, Main.pref.osmDataServer.length()-cutPos);
+			int cutPos = osmDataServer.endsWith("/0.2") ? 4 : 5;
+			Main.pref.put("osmDataServer", osmDataServer.substring(0, osmDataServer.length()-cutPos));
 			try {
 				Main.pref.save();
-			} catch (PreferencesException x) {
+			} catch (IOException x) {
 				x.printStackTrace();
-				JOptionPane.showMessageDialog(Main.main, "Could not save the preferences chane:\n" +
-						x.getMessage());
+				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 73)
+++ src/org/openstreetmap/josm/actions/UploadAction.java	(revision 74)
@@ -5,4 +5,5 @@
 import java.awt.event.InputEvent;
 import java.awt.event.KeyEvent;
+import java.io.IOException;
 import java.util.Collection;
 import java.util.LinkedList;
@@ -17,5 +18,4 @@
 import org.jdom.JDOMException;
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.data.Preferences.PreferencesException;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.gui.OsmPrimitivRenderer;
@@ -40,6 +40,7 @@
 	public void actionPerformed(ActionEvent e) {
 		
+		String osmDataServer = Main.pref.get("osmDataServer");
 		//TODO: Remove this in later versions (temporary only)
-		if (Main.pref.osmDataServer.endsWith("/0.2") || Main.pref.osmDataServer.endsWith("/0.2/")) {
+		if (osmDataServer.endsWith("/0.2") || osmDataServer.endsWith("/0.2/")) {
 			int answer = JOptionPane.showConfirmDialog(Main.main, 
 					"You seem to have an outdated server entry in your preferences.\n" +
@@ -51,12 +52,11 @@
 			if (answer != JOptionPane.YES_OPTION)
 				return;
-			int cutPos = Main.pref.osmDataServer.endsWith("/0.2") ? 4 : 5;
-			Main.pref.osmDataServer = Main.pref.osmDataServer.substring(0, Main.pref.osmDataServer.length()-cutPos);
+			int cutPos = osmDataServer.endsWith("/0.2") ? 4 : 5;
+			Main.pref.put("osmDataServer", osmDataServer.substring(0, osmDataServer.length()-cutPos));
 			try {
 				Main.pref.save();
-			} catch (PreferencesException x) {
+			} catch (IOException x) {
 				x.printStackTrace();
-				JOptionPane.showMessageDialog(Main.main, "Could not save the preferences chane:\n" +
-						x.getMessage());
+				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 73)
+++ src/org/openstreetmap/josm/data/Preferences.java	(revision 74)
@@ -1,24 +1,18 @@
 package org.openstreetmap.josm.data;
 
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.io.File;
 import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.Map.Entry;
 
-import javax.swing.UIManager;
-import javax.swing.UIManager.LookAndFeelInfo;
+import org.openstreetmap.josm.tools.XmlWriter;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
 
-import org.jdom.Element;
-import org.jdom.input.SAXBuilder;
-import org.jdom.output.Format;
-import org.jdom.output.XMLOutputter;
-import org.openstreetmap.josm.data.projection.Epsg4263;
-import org.openstreetmap.josm.data.projection.Mercator;
-import org.openstreetmap.josm.data.projection.Projection;
+import uk.co.wilson.xml.MinML2;
 
 
@@ -26,59 +20,22 @@
  * This class holds all preferences for JOSM.
  * 
+ * Other classes can register their beloved properties here. All properties will be
+ * saved upon set-access.
+ * 
  * @author imi
  */
 public class Preferences {
 
+	public static interface PreferenceChangedListener {
+		void preferenceChanged(String key, String newValue);
+	}
+	
+	ArrayList<PreferenceChangedListener> listener = new ArrayList<PreferenceChangedListener>();
+	
 	/**
-	 * The look and feel. Classname of the look and feel class to use.
+	 * Map the property name to the property object.
 	 */
-	public LookAndFeelInfo laf = UIManager.getInstalledLookAndFeels()[0];
-
-	/**
-	 * The convertor used to translate lat/lon points to screen points.
-	 */
-	private Projection projection = new Epsg4263();
-
-
-	/**
-	 * Whether lines should be drawn between way points of raw gps data.
-	 */
-	private boolean drawRawGpsLines = false;
-	/**
-	 * Force the drawing of lines between raw gps points if there are no
-	 * lines in the imported document.
-	 */
-	private boolean forceRawGpsLines = false;
-
-	/**
-	 * Base URL to the osm data server
-	 */
-	public String osmDataServer = "http://www.openstreetmap.org/api";
-	/**
-	 * The username to the osm server
-	 */
-	public String osmDataUsername = "";
-	/**
-	 * The stored password or <code>null</code>, if the password should not be
-	 * stored.
-	 */
-	public String osmDataPassword = null;
-	/**
-	 * The csv input style string or <code>null</code> for auto. The style is a
-	 * comma seperated list of identifiers as specified in the tooltip help text
-	 * of csvImportString in PreferenceDialog.
-	 * 
-	 * @see org.openstreetmap.josm.gui.PreferenceDialog#csvImportString
-	 */
-	public String csvImportString = null;
-
-	/**
-	 * List of all available Projections.
-	 */
-	public static final Projection[] allProjections = new Projection[]{
-		new Epsg4263(),
-		new Mercator()
-	};
-
+	private SortedMap<String, String> properties = new TreeMap<String, String>();
+	
 	/**
 	 * Return the location of the preferences file
@@ -87,168 +44,79 @@
 		return System.getProperty("user.home")+"/.josm/";
 	}
+
+
+	public void addPreferenceChangedListener(PreferenceChangedListener listener) {
+		this.listener.add(listener);
+	}
+	public void removePreferenceChangedListener(PreferenceChangedListener listener) {
+		this.listener.remove(listener);
+	}
+
+
+	synchronized public String get(String key) {
+		if (!properties.containsKey(key))
+			return "";
+		return properties.get(key);
+	}
+	synchronized public boolean getBoolean(String key) {
+		return properties.containsKey(key) ? Boolean.parseBoolean(properties.get(key)) : false;
+	}
 	
-	/**
-	 * Exception thrown in case of any loading/saving error (including parse errors).
-	 * @author imi
-	 */
-	public static class PreferencesException extends Exception {
-		public PreferencesException(String message, Throwable cause) {
-			super(message, cause);
+	
+	synchronized public void put(String key, String value) {
+		if (value == null)
+			value = "";
+		properties.put(key, value);
+		firePreferenceChanged(key, value);
+	}
+	synchronized public void put(String key, boolean value) {
+		properties.put(key, Boolean.toString(value));
+		firePreferenceChanged(key, Boolean.toString(value));
+	}
+
+	private void firePreferenceChanged(String key, String value) {
+		for (PreferenceChangedListener l : listener)
+			l.preferenceChanged(key, value);
+	}
+
+
+	public void save() throws IOException {
+		PrintWriter out = new PrintWriter(new FileWriter(getPreferencesDir()+"preferences"));
+		out.println(XmlWriter.header());
+		out.println("<josm>");
+		for (Entry<String, String> e : properties.entrySet()) {
+			out.print("  <"+e.getKey());
+			if (!e.getValue().equals(""))
+				out.print(" value='"+XmlWriter.encode(e.getValue())+"'");
+			out.println(" />");
 		}
-		public PreferencesException(String message) {
-			super(message);
-		}
+		out.println("</josm>");
+		out.close();
 	}
-	/**
-	 * Load from disk.
-	 * @throws PreferencesException Any loading error (parse errors as well)
-	 */
-	public void load() throws PreferencesException {
-		File file = new File(getPreferencesDir()+"/preferences");
-		Element root;
+
+
+	public void load() throws IOException {
+		MinML2 reader = new MinML2(){
+			@Override public void startElement(String ns, String name, String qName, Attributes attr) {
+				if (name.equals("josm-settings"))
+					throw new RuntimeException("old version");
+				String v = attr.getValue("value");
+				if (!name.equals("josm"))
+					properties.put(name, v == null ? "" : v);
+			}
+		};
 		try {
-			root = new SAXBuilder().build(new FileReader(file)).getRootElement();
-
-			// laf
-			String lafClassName = root.getChildText("laf");
-			for (LookAndFeelInfo lafInfo : UIManager.getInstalledLookAndFeels())
-				if (lafInfo.getClassName().equals(lafClassName)) {
-					laf = lafInfo;
-					break;
-				}
-			if (laf == null)
-				throw new PreferencesException("Look and Feel not found.", null);
-			
-			// projection
-			Class<?> projectionClass = Class.forName(root.getChildText("projection"));
-			projection = allProjections[0];
-			for (Projection p : allProjections) {
-				if (p.getClass() == projectionClass) {
-					projection = p;
-					break;
-				}
-			}
-
-			Element osmServer = root.getChild("osm-server");
-			if (osmServer != null) {
-				osmDataServer = osmServer.getChildText("url");
-				osmDataUsername = osmServer.getChildText("username");
-				osmDataPassword = osmServer.getChildText("password");
-				csvImportString = osmServer.getChildText("csvImportString");
-			}
-			drawRawGpsLines = root.getChild("drawRawGpsLines") != null;
-			forceRawGpsLines = root.getChild("forceRawGpsLines") != null;
-		} catch (Exception e) {
-			if (e instanceof PreferencesException)
-				throw (PreferencesException)e;
-			throw new PreferencesException("Could not load preferences", e);
-		}
-		
-	}
-	/**
-	 * Save to disk.
-	 * @throws PreferencesException Any saving error (exceeding disk space, etc..)
-	 */
-	@SuppressWarnings("unchecked")
-	public void save() throws PreferencesException {
-		Element root = new Element("josm-settings");
-		
-		List children = root.getChildren();
-		children.add(new Element("laf").setText(laf.getClassName()));
-		children.add(new Element("projection").setText(getProjection().getClass().getName()));
-		if (drawRawGpsLines)
-			children.add(new Element("drawRawGpsLines"));
-		if (forceRawGpsLines)
-			children.add(new Element("forceRawGpsLines"));
-		Element osmServer = new Element("osm-server");
-		osmServer.getChildren().add(new Element("url").setText(osmDataServer));
-		osmServer.getChildren().add(new Element("username").setText(osmDataUsername));
-		osmServer.getChildren().add(new Element("password").setText(osmDataPassword));
-		osmServer.getChildren().add(new Element("csvImportString").setText(csvImportString));
-		children.add(osmServer);
-
-		try {
-			File prefDir = new File(getPreferencesDir());
-			if (prefDir.exists() && !prefDir.isDirectory())
-				throw new PreferencesException("Preferences directory "+getPreferencesDir()+" is not a directory.");
-			if (!prefDir.exists())
-				prefDir.mkdirs();
-
-			FileWriter file = new FileWriter(getPreferencesDir()+"/preferences");
-			new XMLOutputter(Format.getPrettyFormat()).output(root, file);
-			file.close();
-		} catch (IOException e) {
-			throw new PreferencesException("Could not write preferences", e);
+			reader.parse(new FileReader(getPreferencesDir()+"preferences"));
+		} catch (SAXException e) {
+			e.printStackTrace();
+			throw new IOException("Error in preferences file");
 		}
 	}
 
-	// projection change listener stuff
-	
-	/**
-	 * The list of all listeners to projection changes.
-	 */
-	private Collection<PropertyChangeListener> listener = new LinkedList<PropertyChangeListener>();
-
-	/**
-	 * Add a listener of projection changes to the list of listeners.
-	 * @param listener The listerner to add.
-	 */
-	public void addPropertyChangeListener(PropertyChangeListener listener) {
-		if (listener != null)
-			this.listener.add(listener);
-	}
-	/**
-	 * Remove the listener from the list.
-	 */
-	public void removePropertyChangeListener(PropertyChangeListener listener) {
-		this.listener.remove(listener);
-	}
-	/**
-	 * Fires a PropertyChangeEvent if the old value differs from the new value.
-	 */
-	private <T> void firePropertyChanged(String name, T oldValue, T newValue) {
-		if (oldValue == newValue)
-			return;
-		PropertyChangeEvent evt = null;
-		for (PropertyChangeListener l : listener) {
-			if (evt == null)
-				evt = new PropertyChangeEvent(this, name, oldValue, newValue);
-			l.propertyChange(evt);
-		}
-	}
-
-	// getter / setter
-	
-	/**
-	 * Set the projection and fire an event to all ProjectionChangeListener
-	 * @param projection The new Projection.
-	 */
-	public void setProjection(Projection projection) {
-		Projection old = this.projection;
-		this.projection = projection;
-		firePropertyChanged("projection", old, projection);
-	}
-	/**
-	 * Get the current projection.
-	 * @return The current projection set.
-	 */
-	public Projection getProjection() {
-		return projection;
-	}
-	public void setDrawRawGpsLines(boolean drawRawGpsLines) {
-		boolean old = this.drawRawGpsLines;
-		this.drawRawGpsLines = drawRawGpsLines;
-		firePropertyChanged("drawRawGpsLines", old, drawRawGpsLines);
-	}
-	public boolean isDrawRawGpsLines() {
-		return drawRawGpsLines;
-	}
-	public void setForceRawGpsLines(boolean forceRawGpsLines) {
-		boolean old = this.forceRawGpsLines;
-		this.forceRawGpsLines = forceRawGpsLines;
-		firePropertyChanged("forceRawGpsLines", old, forceRawGpsLines);
-	}
-	public boolean isForceRawGpsLines() {
-		return forceRawGpsLines;
+	public void resetToDefault() {
+		properties.clear();
+		properties.put("laf", "javax.swing.plaf.metal.MetalLookAndFeel");
+		properties.put("projection", "org.openstreetmap.josm.data.projection.Epsg4263");
+		properties.put("osmDataServer", "http://www.openstreetmap.org/api");
 	}
 }
Index: src/org/openstreetmap/josm/data/projection/Projection.java
===================================================================
--- src/org/openstreetmap/josm/data/projection/Projection.java	(revision 73)
+++ src/org/openstreetmap/josm/data/projection/Projection.java	(revision 74)
@@ -15,4 +15,12 @@
 	public static double MAX_LON = 180;
 	public static final double MAX_SERVER_PRECISION = 1e12;
+
+	/**
+	 * List of all available Projections.
+	 */
+	public static final Projection[] allProjections = new Projection[]{
+		new Epsg4263(),
+		new Mercator()
+	};
 	
 	/**
Index: src/org/openstreetmap/josm/gui/MapView.java
===================================================================
--- src/org/openstreetmap/josm/gui/MapView.java	(revision 73)
+++ src/org/openstreetmap/josm/gui/MapView.java	(revision 74)
@@ -6,6 +6,4 @@
 import java.awt.event.ComponentAdapter;
 import java.awt.event.ComponentEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -40,5 +38,5 @@
  * @author imi
  */
-public class MapView extends NavigatableComponent implements ChangeListener, PropertyChangeListener  {
+public class MapView extends NavigatableComponent implements ChangeListener {
 
 	/**
@@ -85,11 +83,6 @@
 			}
 		});
-
-		// initialize the movement listener
 		new MapMover(this);
-
-		// initialize the projection
 		addLayer(layer);
-		Main.pref.addPropertyChangeListener(this);
 	}
 
@@ -340,14 +333,3 @@
 		recalculateCenterScale();
 	}
-
-	/**
-	 * Change to the new projection. Recalculate the dataset and zoom, if autoZoom
-	 * is active.
-	 * @param oldProjection The old projection. Unregister from this.
-	 * @param newProjection	The new projection. Register as state change listener.
-	 */
-	public void propertyChange(PropertyChangeEvent evt) {
-		if (evt.getPropertyName().equals("projection"))
-			stateChanged(new ChangeEvent(this));
-	}
 }
Index: src/org/openstreetmap/josm/gui/PreferenceDialog.java
===================================================================
--- src/org/openstreetmap/josm/gui/PreferenceDialog.java	(revision 73)
+++ src/org/openstreetmap/josm/gui/PreferenceDialog.java	(revision 74)
@@ -7,4 +7,5 @@
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.io.IOException;
 
 import javax.swing.AbstractAction;
@@ -28,6 +29,4 @@
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.data.Preferences;
-import org.openstreetmap.josm.data.Preferences.PreferencesException;
 import org.openstreetmap.josm.data.projection.Projection;
 import org.openstreetmap.josm.tools.GBC;
@@ -51,17 +50,18 @@
 		}
 		public void actionPerformed(ActionEvent e) {
-			Main.pref.laf = (LookAndFeelInfo)lafCombo.getSelectedItem();
-			Main.pref.setProjection((Projection)projectionCombo.getSelectedItem());
-			Main.pref.osmDataServer = osmDataServer.getText();
-			Main.pref.osmDataUsername = osmDataUsername.getText();
-			Main.pref.osmDataPassword = String.valueOf(osmDataPassword.getPassword());
-			if (Main.pref.osmDataPassword == "")
-				Main.pref.osmDataPassword = null;
-			Main.pref.csvImportString = csvImportString.getText();
-			Main.pref.setDrawRawGpsLines(drawRawGpsLines.isSelected());
-			Main.pref.setForceRawGpsLines(forceRawGpsLines.isSelected());
+			Main.pref.put("laf", ((LookAndFeelInfo)lafCombo.getSelectedItem()).getClassName());
+			Main.pref.put("projection", projectionCombo.getSelectedItem().getClass().getName());
+			Main.pref.put("osmDataServer", osmDataServer.getText());
+			Main.pref.put("osmDataUsername", osmDataUsername.getText());
+			String pwd = String.valueOf(osmDataPassword.getPassword());
+			if (pwd.equals(""))
+				pwd = null;
+			Main.pref.put("osmDataPassword", pwd);
+			Main.pref.put("csvImportString", csvImportString.getText());
+			Main.pref.put("drawRawGpsLines", drawRawGpsLines.isSelected());
+			Main.pref.put("forceRawGpsLines", forceRawGpsLines.isSelected());
 			try {
 				Main.pref.save();
-			} catch (PreferencesException x) {
+			} catch (IOException x) {
 				x.printStackTrace();
 				JOptionPane.showMessageDialog(PreferenceDialog.this, "Could not save preferences:\n"+x.getMessage());
@@ -98,5 +98,5 @@
 	 * Combobox with all projections available
 	 */
-	JComboBox projectionCombo = new JComboBox(Preferences.allProjections);
+	JComboBox projectionCombo = new JComboBox(Projection.allProjections);
 	/**
 	 * The main tab panel.
@@ -140,19 +140,20 @@
 
 		// look and feel combo box
+		lafCombo.setSelectedItem(Main.pref.get("laf"));
 		final ListCellRenderer oldRenderer = lafCombo.getRenderer();
 		lafCombo.setRenderer(new DefaultListCellRenderer(){
-			@Override
-			public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+			@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
 				return oldRenderer.getListCellRendererComponent(list, ((LookAndFeelInfo)value).getName(), index, isSelected, cellHasFocus);
-			}});
-		lafCombo.setSelectedItem(Main.pref.laf);
+			}
+		});
 		lafCombo.addActionListener(new ActionListener(){
 			public void actionPerformed(ActionEvent e) {
 				requiresRestart = true;
-			}});
+			}
+		});
 
 		// projection combo box
 		for (int i = 0; i < projectionCombo.getItemCount(); ++i) {
-			if (projectionCombo.getItemAt(i).getClass().equals(Main.pref.getProjection().getClass())) {
+			if (projectionCombo.getItemAt(i).toString().equals(Main.pref.get("projection"))) {
 				projectionCombo.setSelectedIndex(i);
 				break;
@@ -185,13 +186,13 @@
 				"Other example: \"lat,lon\" will just read lat/lon values comma seperated.</html>");
 		drawRawGpsLines.setToolTipText("If your gps device draw to few lines, select this to draw lines along your way.");
-		drawRawGpsLines.setSelected(Main.pref.isDrawRawGpsLines());
+		drawRawGpsLines.setSelected(Main.pref.getBoolean("drawRawGpsLines"));
 		forceRawGpsLines.setToolTipText("Force drawing of lines if the imported data contain no line information.");
-		forceRawGpsLines.setSelected(Main.pref.isForceRawGpsLines());
+		forceRawGpsLines.setSelected(Main.pref.getBoolean("forceRawGpsLines"));
 		forceRawGpsLines.setEnabled(drawRawGpsLines.isSelected());
 
-		osmDataServer.setText(Main.pref.osmDataServer);
-		osmDataUsername.setText(Main.pref.osmDataUsername);
-		osmDataPassword.setText(Main.pref.osmDataPassword);
-		csvImportString.setText(Main.pref.csvImportString);
+		osmDataServer.setText(Main.pref.get("osmDataServer"));
+		osmDataUsername.setText(Main.pref.get("osmDataUsername"));
+		osmDataPassword.setText(Main.pref.get("osmDataPassword"));
+		csvImportString.setText(Main.pref.get("csvImportString"));
 
 		// Display tab
Index: src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
===================================================================
--- src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java	(revision 73)
+++ src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java	(revision 74)
@@ -2,6 +2,4 @@
 
 import java.awt.Graphics;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
 import java.util.Collection;
 import java.util.HashSet;
@@ -81,11 +79,4 @@
 		this.data = data;
 		this.fromDisk = fromDisk;
-		Main.pref.addPropertyChangeListener(new PropertyChangeListener() {
-			public void propertyChange(PropertyChangeEvent evt) {
-				if (evt.getPropertyName().equals("projection"))
-					for (Node n : OsmDataLayer.this.data.nodes)
-						((Projection)evt.getNewValue()).latlon2eastNorth(n.coor);
-			}
-		});
 	}
 
Index: src/org/openstreetmap/josm/gui/layer/RawGpsDataLayer.java
===================================================================
--- src/org/openstreetmap/josm/gui/layer/RawGpsDataLayer.java	(revision 73)
+++ src/org/openstreetmap/josm/gui/layer/RawGpsDataLayer.java	(revision 74)
@@ -4,6 +4,4 @@
 import java.awt.Graphics;
 import java.awt.Point;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
 import java.util.Collection;
 import java.util.LinkedList;
@@ -12,6 +10,7 @@
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener;
+import org.openstreetmap.josm.data.coor.EastNorth;
 import org.openstreetmap.josm.data.coor.LatLon;
-import org.openstreetmap.josm.data.coor.EastNorth;
 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
 import org.openstreetmap.josm.data.projection.Projection;
@@ -39,12 +38,11 @@
 		this.data = data;
 		
-		Main.pref.addPropertyChangeListener(new PropertyChangeListener(){
-			public void propertyChange(PropertyChangeEvent evt) {
+		Main.pref.addPreferenceChangedListener(new PreferenceChangedListener(){
+			public void preferenceChanged(String key, String newValue) {
 				if (Main.main.getMapFrame() == null) {
-					Main.pref.removePropertyChangeListener(this);
+					Main.pref.removePreferenceChangedListener(this);
 					return;
 				}
-				if (evt.getPropertyName().equals("drawRawGpsLines") ||
-						evt.getPropertyName().equals("forceRawGpsLines"))
+				if (key.equals("drawRawGpsLines") || key.equals("forceRawGpsLines"))
 					Main.main.getMapFrame().repaint();
 			}
@@ -67,9 +65,9 @@
 		Point old = null;
 		for (Collection<EastNorth> c : eastNorth) {
-			if (!Main.pref.isForceRawGpsLines())
+			if (!Main.pref.getBoolean("forceRawGpsLines"))
 				old = null;
 			for (EastNorth eastNorth : c) {
 				Point screen = mv.getPoint(eastNorth);
-				if (Main.pref.isDrawRawGpsLines() && old != null)
+				if (Main.pref.getBoolean("drawRawGpsLines") && old != null)
 					g.drawLine(old.x, old.y, screen.x, screen.y);
 				else
Index: src/org/openstreetmap/josm/io/OsmConnection.java
===================================================================
--- src/org/openstreetmap/josm/io/OsmConnection.java	(revision 73)
+++ src/org/openstreetmap/josm/io/OsmConnection.java	(revision 74)
@@ -39,13 +39,13 @@
 		@Override
 		protected PasswordAuthentication getPasswordAuthentication() {
-			String username = Main.pref.osmDataUsername;
-			String password = Main.pref.osmDataPassword;
-			if (passwordtried || "".equals(username) || password == null || "".equals(password)) {
+			String username = Main.pref.get("osmDataUsername");
+			String password = Main.pref.get("osmDataPassword");
+			if (passwordtried || username.equals("") || password.equals("")) {
 				JPanel p = new JPanel(new GridBagLayout());
 				p.add(new JLabel("Username"), GBC.std().insets(0,0,10,0));
-				JTextField usernameField = new JTextField("".equals(username) ? "" : username, 20);
+				JTextField usernameField = new JTextField(username, 20);
 				p.add(usernameField, GBC.eol());
 				p.add(new JLabel("Password"), GBC.std().insets(0,0,10,0));
-				JPasswordField passwordField = new JPasswordField(password == null ? "" : password, 20);
+				JPasswordField passwordField = new JPasswordField(password, 20);
 				p.add(passwordField, GBC.eol());
 				JLabel warning = new JLabel("Warning: The password is transferred unencrypted.");
@@ -59,5 +59,5 @@
 				username = usernameField.getText();
 				password = String.valueOf(passwordField.getPassword());
-				if ("".equals(username))
+				if (username.equals(""))
 					return null;
 			}
Index: src/org/openstreetmap/josm/io/OsmServerReader.java
===================================================================
--- src/org/openstreetmap/josm/io/OsmServerReader.java	(revision 73)
+++ src/org/openstreetmap/josm/io/OsmServerReader.java	(revision 74)
@@ -48,5 +48,5 @@
 	 */
 	public Collection<Collection<LatLon>> parseRawGps() throws IOException, JDOMException {
-		String url = Main.pref.osmDataServer+"/0.3/trackpoints?bbox="+lon1+","+lat1+","+lon2+","+lat2+"&page=";
+		String url = Main.pref.get("osmDataServer")+"/0.3/trackpoints?bbox="+lon1+","+lat1+","+lon2+","+lat2+"&page=";
 		Collection<Collection<LatLon>> data = new LinkedList<Collection<LatLon>>();
 		Collection<LatLon> list = new LinkedList<LatLon>();
@@ -80,5 +80,5 @@
 	 */
 	public DataSet parseOsm() throws SAXException, IOException {
-		Reader r = getReader(Main.pref.osmDataServer+"/0.3/map?bbox="+lon1+","+lat1+","+lon2+","+lat2);
+		Reader r = getReader(Main.pref.get("osmDataServer")+"/0.3/map?bbox="+lon1+","+lat1+","+lon2+","+lat2);
 		if (r == null)
 			return null;
Index: src/org/openstreetmap/josm/io/OsmServerWriter.java
===================================================================
--- src/org/openstreetmap/josm/io/OsmServerWriter.java	(revision 73)
+++ src/org/openstreetmap/josm/io/OsmServerWriter.java	(revision 74)
@@ -136,5 +136,5 @@
 			OsmPrimitive osm, boolean addBody) {
 		try {
-			URL url = new URL(Main.pref.osmDataServer + "/0.3/" + urlSuffix + "/" + osm.id);
+			URL url = new URL(Main.pref.get("osmDataServer") + "/0.3/" + urlSuffix + "/" + osm.id);
 			System.out.println("upload to: "+url);
 			HttpURLConnection con = (HttpURLConnection) url.openConnection();
Index: src/org/openstreetmap/josm/io/RawCsvReader.java
===================================================================
--- src/org/openstreetmap/josm/io/RawCsvReader.java	(revision 73)
+++ src/org/openstreetmap/josm/io/RawCsvReader.java	(revision 74)
@@ -30,5 +30,5 @@
 	public Collection<LatLon> parse() throws JDOMException, IOException {
 		Collection<LatLon> data = new LinkedList<LatLon>();
-		String formatStr = Main.pref.csvImportString;
+		String formatStr = Main.pref.get("csvImportString");
 		if (formatStr == null)
 			formatStr = in.readLine();
@@ -52,7 +52,7 @@
 		// test for completness
 		if (!format.contains("lat") || !format.contains("lon")) {
-			if (Main.pref.csvImportString != null)
-				throw new JDOMException("Format string is incomplete. Need at least 'lat' and 'lon' specification");
-			throw new JDOMException("Format string in data is incomplete or not found. Try setting an manual format string in Preferences.");
+			if (Main.pref.get("csvImportString").equals(""))
+				throw new JDOMException("Format string in data is incomplete or not found. Try setting an manual format string in Preferences.");
+			throw new JDOMException("Format string is incomplete. Need at least 'lat' and 'lon' specification");
 		}
 		
@@ -71,5 +71,5 @@
 						st.nextToken();
 					else
-						throw new JDOMException("Unknown data type: '"+token+"'."+(Main.pref.csvImportString == null ? " Maybe add an format string in preferences." : ""));
+						throw new JDOMException("Unknown data type: '"+token+"'."+(Main.pref.get("csvImportString").equals("") ? " Maybe add an format string in preferences." : ""));
 				}
 				data.add(new LatLon(lat, lon));
Index: src/org/openstreetmap/josm/tools/XmlWriter.java
===================================================================
--- src/org/openstreetmap/josm/tools/XmlWriter.java	(revision 73)
+++ src/org/openstreetmap/josm/tools/XmlWriter.java	(revision 74)
@@ -31,5 +31,5 @@
 	 * @return The standard XML1.0 header. Encoding is utf-8
 	 */
-	public static Object header() {
+	public static String header() {
 		return "<?xml version='1.0' encoding='UTF-8'?>";
 	}
