Index: trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java	(revision 2985)
+++ trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java	(revision 2986)
@@ -47,6 +47,5 @@
         if (Main.main == null || Main.main.getEditLayer() == null) return;
         if (Main.map == null || Main.map.mapView == null) return;
-        Collection<OsmPrimitive> sel = new HashSet<OsmPrimitive>();
-        sel = Main.main.getEditLayer().data.getSelected();
+        Collection<OsmPrimitive> sel = Main.main.getEditLayer().data.getSelected();
         if (sel.isEmpty()) {
             JOptionPane.showMessageDialog(
Index: trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java	(revision 2985)
+++ trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java	(revision 2986)
@@ -348,18 +348,16 @@
         if(currentMode.equals(c) || (!drawTargetCursor && currentMode.equals(DeleteMode.none)))
             return;
-        try {
-            // We invoke this to prevent strange things from happening
-            EventQueue.invokeLater(new Runnable() {
-                public void run() {
-                    // Don't change cursor when mode has changed already
-                    if(!(Main.map.mapMode instanceof DeleteAction))
-                        return;
-
-                    Main.map.mapView.setCursor(c.cursor());
-                    //System.out.println("Set cursor to: " + c.name());
-                }
-            });
-            currentMode = c;
-        } catch(Exception e) {}
+        // We invoke this to prevent strange things from happening
+        EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                // Don't change cursor when mode has changed already
+                if(!(Main.map.mapMode instanceof DeleteAction))
+                    return;
+
+                Main.map.mapView.setCursor(c.cursor());
+                //System.out.println("Set cursor to: " + c.name());
+            }
+        });
+        currentMode = c;
     }
 
Index: trunk/src/org/openstreetmap/josm/data/osm/ChangesetCache.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/ChangesetCache.java	(revision 2985)
+++ trunk/src/org/openstreetmap/josm/data/osm/ChangesetCache.java	(revision 2986)
@@ -60,17 +60,9 @@
 
     public void addChangesetCacheListener(ChangesetCacheListener listener) {
-        synchronized(listeners) {
-            if (listener != null && ! listeners.contains(listener)) {
-                listeners.add(listener);
-            }
-        }
+        listeners.addIfAbsent(listener);
     }
 
     public void removeChangesetCacheListener(ChangesetCacheListener listener) {
-        synchronized(listeners) {
-            if (listener != null && listeners.contains(listener)) {
-                listeners.remove(listener);
-            }
-        }
+        listeners.remove(listener);
     }
 
Index: trunk/src/org/openstreetmap/josm/data/osm/DataSource.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/DataSource.java	(revision 2985)
+++ trunk/src/org/openstreetmap/josm/data/osm/DataSource.java	(revision 2986)
@@ -4,5 +4,5 @@
 import org.openstreetmap.josm.data.Bounds;
 
-public class DataSource implements Cloneable {
+public class DataSource {
     public final Bounds bounds;
     public final String origin;
@@ -11,11 +11,6 @@
         this.bounds = bounds;
         this.origin = origin;
-        if (bounds == null) {
+        if (bounds == null)
             throw new NullPointerException();
-        }
-    }
-
-    @Override protected Object clone() throws CloneNotSupportedException {
-        return new DataSource(bounds, origin);
     }
 }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java	(revision 2985)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java	(revision 2986)
@@ -552,5 +552,4 @@
             DataSet.selListeners.remove(selectionTableModel);
             getLayer().data.removeDataSetListener(memberTableModel);
-            getLayer().listenerDataChanged.remove(memberTableModel);
             memberTable.unlinkAsListener();
             dispose();
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java	(revision 2985)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java	(revision 2986)
@@ -44,6 +44,6 @@
      */
     static private class DialogContext {
-        public Relation relation;
-        public OsmDataLayer layer;
+        public final Relation relation;
+        public final OsmDataLayer layer;
 
         public DialogContext(OsmDataLayer layer, Relation relation) {
@@ -94,5 +94,5 @@
 
     /** the map of open dialogs */
-    private HashMap<DialogContext, RelationEditor> openDialogs;
+    private final HashMap<DialogContext, RelationEditor> openDialogs;
 
     /**
Index: trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java	(revision 2985)
+++ trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java	(revision 2986)
@@ -842,5 +842,4 @@
             OsmDataLayer l = (OsmDataLayer)oldLayer;
             l.data.removeDataSetListener(this);
-            l.listenerDataChanged.remove(this);
         }
         if (newLayer == null || ! (newLayer instanceof OsmDataLayer)) {
Index: trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java	(revision 2985)
+++ trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java	(revision 2986)
@@ -125,7 +125,6 @@
             selectedRect = null;
 
-            if (image == null) {
-                return;
-            }
+            if (image == null)
+                return;
 
             // Calculate the mouse cursor position in image coordinates, so that we can center the zoom
@@ -196,11 +195,9 @@
             }
 
-            if (image == null) {
-                return;
-            }
-
-            if (e.getButton() != DRAG_BUTTON) {
-                return;
-            }
+            if (image == null)
+                return;
+
+            if (e.getButton() != DRAG_BUTTON)
+                return;
 
             // Calculate the translation to set the clicked point the center of the view.
@@ -230,17 +227,14 @@
             }
 
-            File file;
             Image image;
             Rectangle visibleRect;
 
             synchronized (ImageDisplay.this) {
-                file = ImageDisplay.this.file;
                 image = ImageDisplay.this.image;
                 visibleRect = ImageDisplay.this.visibleRect;
             }
 
-            if (image == null) {
-                return;
-            }
+            if (image == null)
+                return;
 
             if (e.getButton() == DRAG_BUTTON) {
@@ -261,7 +255,6 @@
 
         public void mouseDragged(MouseEvent e) {
-            if (! mouseIsDragging && selectedRect == null) {
-                return;
-            }
+            if (! mouseIsDragging && selectedRect == null)
+                return;
 
             File file;
@@ -310,16 +303,13 @@
 
         public void mouseReleased(MouseEvent e) {
-            if (! mouseIsDragging && selectedRect == null) {
-                return;
-            }
+            if (! mouseIsDragging && selectedRect == null)
+                return;
 
             File file;
             Image image;
-            Rectangle visibleRect;
 
             synchronized (ImageDisplay.this) {
                 file = ImageDisplay.this.file;
                 image = ImageDisplay.this.image;
-                visibleRect = ImageDisplay.this.visibleRect;
             }
 
@@ -424,4 +414,5 @@
     }
 
+    @Override
     public void paintComponent(Graphics g) {
         Image image;
@@ -443,11 +434,11 @@
             Dimension size = getSize();
             g.drawString(noImageStr,
-                         (int) ((size.width - noImageSize.getWidth()) / 2),
-                         (int) ((size.height - noImageSize.getHeight()) / 2));
+                    (int) ((size.width - noImageSize.getWidth()) / 2),
+                    (int) ((size.height - noImageSize.getHeight()) / 2));
         } else if (image == null) {
             g.setColor(Color.black);
             String loadingStr;
             if (! errorLoading) {;
-                loadingStr = tr("Loading {0}", file.getName());
+            loadingStr = tr("Loading {0}", file.getName());
             } else {
                 loadingStr = tr("Error on file {0}", file.getName());
@@ -456,17 +447,17 @@
             Dimension size = getSize();
             g.drawString(loadingStr,
-                         (int) ((size.width - noImageSize.getWidth()) / 2),
-                         (int) ((size.height - noImageSize.getHeight()) / 2));
+                    (int) ((size.width - noImageSize.getWidth()) / 2),
+                    (int) ((size.height - noImageSize.getHeight()) / 2));
         } else {
             Rectangle target = calculateDrawImageRectangle(visibleRect);
             g.drawImage(image,
-                        target.x, target.y, target.x + target.width, target.y + target.height,
-                        visibleRect.x, visibleRect.y, visibleRect.x + visibleRect.width, visibleRect.y + visibleRect.height,
-                        null);
+                    target.x, target.y, target.x + target.width, target.y + target.height,
+                    visibleRect.x, visibleRect.y, visibleRect.x + visibleRect.width, visibleRect.y + visibleRect.height,
+                    null);
             if (selectedRect != null) {
                 Point topLeft = img2compCoord(visibleRect, selectedRect.x, selectedRect.y);
                 Point bottomRight = img2compCoord(visibleRect,
-                                                  selectedRect.x + selectedRect.width,
-                                                  selectedRect.y + selectedRect.height);
+                        selectedRect.x + selectedRect.width,
+                        selectedRect.y + selectedRect.height);
                 g.setColor(new Color(128, 128, 128, 180));
                 g.fillRect(target.x, target.y, target.width, topLeft.y - target.y);
@@ -482,6 +473,6 @@
                 Dimension size = getSize();
                 g.drawString(loadingStr,
-                             (int) ((size.width - noImageSize.getWidth()) / 2),
-                             (int) ((size.height - noImageSize.getHeight()) / 2));
+                        (int) ((size.width - noImageSize.getWidth()) / 2),
+                        (int) ((size.height - noImageSize.getHeight()) / 2));
             }
             if (osdText != null) {
@@ -519,5 +510,5 @@
         Rectangle drawRect = calculateDrawImageRectangle(visibleRect);
         return new Point(drawRect.x + ((xImg - visibleRect.x) * drawRect.width) / visibleRect.width,
-                         drawRect.y + ((yImg - visibleRect.y) * drawRect.height) / visibleRect.height);
+                drawRect.y + ((yImg - visibleRect.y) * drawRect.height) / visibleRect.height);
     }
 
@@ -525,10 +516,10 @@
         Rectangle drawRect = calculateDrawImageRectangle(visibleRect);
         return new Point(visibleRect.x + ((xComp - drawRect.x) * visibleRect.width) / drawRect.width,
-                         visibleRect.y + ((yComp - drawRect.y) * visibleRect.height) / drawRect.height);
-    }
-
-   private final Point getCenterImgCoord(Rectangle visibleRect) {
+                visibleRect.y + ((yComp - drawRect.y) * visibleRect.height) / drawRect.height);
+    }
+
+    private final Point getCenterImgCoord(Rectangle visibleRect) {
         return new Point(visibleRect.x + visibleRect.width / 2,
-                                 visibleRect.y + visibleRect.height / 2);
+                visibleRect.y + visibleRect.height / 2);
     }
 
@@ -576,7 +567,6 @@
         }
 
-        if (image == null) {
+        if (image == null)
             return;
-        }
 
         if (visibleRect.width != image.getWidth(null) || visibleRect.height != image.getHeight(null)) {
@@ -588,5 +578,5 @@
             Point center = getCenterImgCoord(visibleRect);
             visibleRect = new Rectangle(center.x - getWidth() / 2, center.y - getHeight() / 2,
-                                        getWidth(), getHeight());
+                    getWidth(), getHeight());
             checkVisibleRectPos(image, visibleRect);
         }
Index: trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ThumbsLoader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ThumbsLoader.java	(revision 2985)
+++ trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ThumbsLoader.java	(revision 2986)
@@ -2,6 +2,4 @@
 
 package org.openstreetmap.josm.gui.layer.geoimage;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
 
 import java.awt.Graphics2D;
@@ -11,113 +9,111 @@
 import java.awt.Toolkit;
 import java.awt.image.BufferedImage;
-import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.io.CacheFiles;
-import org.openstreetmap.josm.Main;
 
 public class ThumbsLoader implements Runnable {
-        public static final int maxSize = 120;
-        public static final int minSize = 22;
-        volatile boolean stop = false;
-        List<ImageEntry> data;
-        GeoImageLayer layer;
-        MediaTracker tracker;
-        CacheFiles cache;
-        boolean cacheOff = Main.pref.getBoolean("geoimage.noThumbnailCache", false);
+    public static final int maxSize = 120;
+    public static final int minSize = 22;
+    volatile boolean stop = false;
+    List<ImageEntry> data;
+    GeoImageLayer layer;
+    MediaTracker tracker;
+    CacheFiles cache;
+    boolean cacheOff = Main.pref.getBoolean("geoimage.noThumbnailCache", false);
 
-        public ThumbsLoader(GeoImageLayer layer) {
-            this.layer = layer;
-            this.data = new ArrayList<ImageEntry>(layer.data);
-            if (!cacheOff) {
-                cache = new CacheFiles("geoimage-thumbnails", false);
-                cache.setExpire(CacheFiles.EXPIRE_NEVER, false);
-                cache.setMaxSize(120, false);
+    public ThumbsLoader(GeoImageLayer layer) {
+        this.layer = layer;
+        this.data = new ArrayList<ImageEntry>(layer.data);
+        if (!cacheOff) {
+            cache = new CacheFiles("geoimage-thumbnails", false);
+            cache.setExpire(CacheFiles.EXPIRE_NEVER, false);
+            cache.setMaxSize(120, false);
+        }
+    }
+
+    public void run() {
+        System.err.println("Load Thumbnails");
+        tracker = new MediaTracker(Main.map.mapView);
+        for (int i = 0; i < data.size(); i++) {
+            if (stop) return;
+
+            System.err.print("fetching image "+i);
+
+            data.get(i).thumbnail = loadThumb(data.get(i));
+
+            if (Main.map != null && Main.map.mapView != null) {
+                layer.updateOffscreenBuffer = true;
+                Main.map.mapView.repaint();
+            }
+        }
+        try {
+            layer.updateOffscreenBuffer = true;
+        } catch (Exception e) {}
+        Main.map.mapView.repaint();
+        (new Thread() {             // clean up the garbage - shouldn't hurt
+            @Override
+            public void run() {
+                try {
+                    Thread.sleep(200);
+                }
+                catch (InterruptedException ie) {}
+                System.gc();
+            }
+        }).start();
+
+    }
+
+    private BufferedImage loadThumb(ImageEntry entry) {
+        final String cacheIdent = entry.getFile().toString()+":"+maxSize;
+
+        if (!cacheOff) {
+            BufferedImage cached = cache.getImg(cacheIdent);
+            if(cached != null) {
+                System.err.println(" from cache");
+                return cached;
             }
         }
 
-        public void run() {
-            System.err.println("Load Thumbnails");
-            tracker = new MediaTracker(Main.map.mapView);
-            for (int i = 0; i < data.size(); i++) {
-                if (stop) return;
+        Image img = Toolkit.getDefaultToolkit().createImage(entry.getFile().getPath());
+        tracker.addImage(img, 0);
+        try {
+            tracker.waitForID(0);
+        } catch (InterruptedException e) {
+            System.err.println(" InterruptedException");
+            return null;
+        }
+        if (tracker.isErrorID(1) || img.getWidth(null) <= 0 || img.getHeight(null) <= 0) {
+            System.err.println(" Invalid image");
+            return null;
+        }
+        Rectangle targetSize = ImageDisplay.calculateDrawImageRectangle(
+                new Rectangle(0, 0, img.getWidth(null), img.getHeight(null)),
+                new Rectangle(0, 0, maxSize, maxSize));
+        BufferedImage scaledBI = new BufferedImage(targetSize.width, targetSize.height, BufferedImage.TYPE_INT_RGB);
+        Graphics2D g = scaledBI.createGraphics();
+        while (!g.drawImage(img, 0, 0, targetSize.width, targetSize.height, null))
+        {
+            try {
+                Thread.sleep(10);
+            } catch(InterruptedException ie) {}
+        }
+        g.dispose();
+        tracker.removeImage(img);
 
-                System.err.print("fetching image "+i);
-
-                data.get(i).thumbnail = loadThumb(data.get(i));
-
-                if (Main.map != null && Main.map.mapView != null) {
-                    try {
-                        layer.updateOffscreenBuffer = true;
-                    } catch (Exception e) {}
-                    Main.map.mapView.repaint();
-                }
-            }
-            try {
-                layer.updateOffscreenBuffer = true;
-            } catch (Exception e) {}
-            Main.map.mapView.repaint();
-            (new Thread() {             // clean up the garbage - shouldn't hurt
-                public void run() {
-                    try {
-                        Thread.sleep(200);
-                    }
-                    catch (InterruptedException ie) {}
-                    System.gc();
-                }
-            }).start();
-
+        if (scaledBI.getWidth() <= 0 || scaledBI.getHeight() <= 0) {
+            System.err.println(" Invalid image");
+            return null;
         }
 
-        private BufferedImage loadThumb(ImageEntry entry) {
-            final String cacheIdent = entry.getFile().toString()+":"+maxSize;
-
-            if (!cacheOff) {
-                BufferedImage cached = cache.getImg(cacheIdent);
-                if(cached != null) {
-                    System.err.println(" from cache");
-                    return cached;
-                }
-            }
-
-            Image img = Toolkit.getDefaultToolkit().createImage(entry.getFile().getPath());
-            tracker.addImage(img, 0);
-            try {
-                tracker.waitForID(0);
-            } catch (InterruptedException e) {
-                System.err.println(" InterruptedException");
-                return null;
-            }
-            if (tracker.isErrorID(1) || img.getWidth(null) <= 0 || img.getHeight(null) <= 0) {
-                System.err.println(" Invalid image");
-                return null;
-            }
-            Rectangle targetSize = ImageDisplay.calculateDrawImageRectangle(
-                new Rectangle(0, 0, img.getWidth(null), img.getHeight(null)),
-                new Rectangle(0, 0, maxSize, maxSize));
-            BufferedImage scaledBI = new BufferedImage(targetSize.width, targetSize.height, BufferedImage.TYPE_INT_RGB);
-            Graphics2D g = scaledBI.createGraphics();
-            while (!g.drawImage(img, 0, 0, targetSize.width, targetSize.height, null))
-            {
-                try {
-                    Thread.sleep(10);
-                } catch(InterruptedException ie) {}
-            }
-            g.dispose();
-            tracker.removeImage(img);
-
-            if (scaledBI == null || scaledBI.getWidth() <= 0 || scaledBI.getHeight() <= 0) {
-                System.err.println(" Invalid image");
-                return null;
-            }
-
-            if (!cacheOff) {
-                cache.saveImg(cacheIdent, scaledBI);
-            }
-
-            System.err.println("");
-            return scaledBI;
+        if (!cacheOff) {
+            cache.saveImg(cacheIdent, scaledBI);
         }
 
+        System.err.println("");
+        return scaledBI;
     }
+
+}
Index: trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferencesModel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferencesModel.java	(revision 2985)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferencesModel.java	(revision 2986)
@@ -39,5 +39,5 @@
             displayedPlugins.clear();
             displayedPlugins.addAll(availablePlugins);
-            this.filterExpression = filter;
+            this.filterExpression = null;
             return;
         }
Index: trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java	(revision 2985)
+++ trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java	(revision 2986)
@@ -7,4 +7,5 @@
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.util.Date;
 
@@ -124,6 +125,7 @@
      */
     public byte[] getData() {
-        if(data == null)
+        if(data == null) {
             loadFromDisk();
+        }
         return data;
     }
@@ -146,5 +148,5 @@
             input.read(this.data);
             input.close();
-        } catch(Exception e) {
+        } catch(IOException e) {
             this.data = updateForce();
         }
@@ -160,5 +162,7 @@
             output.flush();
             output.close();
-        } catch(Exception e) {}
+        } catch(Exception e) {
+            e.printStackTrace();
+        }
     }
 
Index: trunk/src/org/openstreetmap/josm/io/CacheFiles.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/CacheFiles.java	(revision 2985)
+++ trunk/src/org/openstreetmap/josm/io/CacheFiles.java	(revision 2986)
@@ -43,7 +43,7 @@
 
     // If the cache is full, we don't want to delete just one file
-    private final int cleanUpThreshold = 20;
+    private static final int cleanUpThreshold = 20;
     // We don't want to clean after every file-write
-    private final int cleanUpInterval = 5;
+    private static final int cleanUpInterval = 5;
     // Stores how many files have been written
     private int writes = 0;
