Index: trunk/src/org/openstreetmap/josm/data/Preferences.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 3546)
+++ trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 3547)
@@ -26,6 +26,4 @@
 import java.util.Map.Entry;
 import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 import javax.swing.JOptionPane;
@@ -205,8 +203,9 @@
     synchronized public Map<String, String> getAllPrefix(final String prefix) {
         final Map<String,String> all = new TreeMap<String,String>();
-        for (final Entry<String,String> e : properties.entrySet())
+        for (final Entry<String,String> e : properties.entrySet()) {
             if (e.getKey().startsWith(prefix)) {
                 all.put(e.getKey(), e.getValue());
             }
+        }
         return all;
     }
@@ -214,8 +213,9 @@
     synchronized private Map<String, String> getAllPrefixDefault(final String prefix) {
         final Map<String,String> all = new TreeMap<String,String>();
-        for (final Entry<String,String> e : defaults.entrySet())
+        for (final Entry<String,String> e : defaults.entrySet()) {
             if (e.getKey().startsWith(prefix)) {
                 all.put(e.getKey(), e.getValue());
             }
+        }
         return all;
     }
@@ -223,12 +223,14 @@
     synchronized public TreeMap<String, String> getAllColors() {
         final TreeMap<String,String> all = new TreeMap<String,String>();
-        for (final Entry<String,String> e : defaults.entrySet())
+        for (final Entry<String,String> e : defaults.entrySet()) {
             if (e.getKey().startsWith("color.") && e.getValue() != null) {
                 all.put(e.getKey().substring(6), e.getValue());
             }
-        for (final Entry<String,String> e : properties.entrySet())
+        }
+        for (final Entry<String,String> e : properties.entrySet()) {
             if (e.getKey().startsWith("color.")) {
                 all.put(e.getKey().substring(6), e.getValue());
             }
+        }
         return all;
     }
@@ -579,4 +581,5 @@
         return def;
     }
+
     synchronized public void removeFromCollection(String key, String value) {
         List<String> a = new ArrayList<String>(getCollection(key, Collections.<String>emptyList()));
@@ -584,4 +587,5 @@
         putCollection(key, a);
     }
+
     synchronized public boolean putCollection(String key, Collection<String> val) {
         String s = null;
@@ -590,4 +594,7 @@
             for(String a : val)
             {
+                if (a == null) {
+                    a = "";
+                }
                 if(s != null) {
                     s += "\u001e" + a;
@@ -599,4 +606,5 @@
         return put(key, s);
     }
+    
     synchronized private void putCollectionDefault(String key, Collection<String> val) {
         String s = null;
@@ -611,4 +619,5 @@
         putDefault(key, s);
     }
+    
     synchronized public Collection<Collection<String>> getArray(String key,
     Collection<Collection<String>> def) {
@@ -618,10 +627,12 @@
         int num = 0;
         Collection<Collection<String>> col = new LinkedList<Collection<String>>();
-        while(properties.containsKey(key+num))
+        while(properties.containsKey(key+num)) {
             col.add(getCollection(key+num++, null));
+        }
         return num == 0 && def != null ? def : col;
     }
+    
     synchronized public boolean putArray(String key, Collection<Collection<String>> val) {
-        boolean res = true;
+        boolean changed = false;
         key += ".";
         Collection<String> keys = getAllPrefix(key).keySet();
@@ -630,6 +641,5 @@
             for(Collection<String> c : val) {
                 keys.remove(key+num);
-                if(!putCollection(key+num++, c))
-                    res = false;
+                changed |= putCollection(key+num++, c);
             }
         }
@@ -638,9 +648,11 @@
             try {
               Integer.valueOf(k.substring(l));
-              put(k, null);
-            } catch(Exception e) {
-            }
-        }
-        return res;
+              changed |= put(k, null);
+            } catch(NumberFormatException e) {
+                System.err.println("Warning: invalid preference.");
+                e.printStackTrace();
+            }
+        }
+        return changed;
     }
 
