Index: /trunk/src/org/openstreetmap/josm/actions/ValidateAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/ValidateAction.java	(revision 5462)
+++ /trunk/src/org/openstreetmap/josm/actions/ValidateAction.java	(revision 5463)
@@ -45,6 +45,6 @@
     public ValidateAction() {
         super(tr("Validation"), "dialogs/validator", tr("Performs the data validation"),
-            Shortcut.registerShortcut("tools:validate", tr("Tool: {0}", tr("Validation")),
-            KeyEvent.VK_V, Shortcut.SHIFT), true);
+                Shortcut.registerShortcut("tools:validate", tr("Tool: {0}", tr("Validation")),
+                        KeyEvent.VK_V, Shortcut.SHIFT), true);
     }
 
@@ -64,5 +64,5 @@
      */
     public void doValidate(ActionEvent ev, boolean getSelectedItems) {
-        if (Main.main.validator.validateAction == null || Main.map == null || !Main.map.isVisible())
+        if (Main.map == null || !Main.map.isVisible())
             return;
 
Index: /trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java	(revision 5462)
+++ /trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java	(revision 5463)
@@ -22,5 +22,4 @@
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.actions.ValidateAction;
 import org.openstreetmap.josm.data.projection.Epsg4326;
 import org.openstreetmap.josm.data.projection.Lambert;
@@ -68,7 +67,4 @@
     public static ValidatorLayer errorLayer = null;
 
-    /** The validate action */
-    public ValidateAction validateAction = new ValidateAction();
-
     /** Grid detail, multiplier of east,north values for valuable cell sizing */
     public static double griddetail;
Index: /trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java	(revision 5462)
+++ /trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java	(revision 5463)
@@ -27,5 +27,5 @@
 
 public class ImageryMenu extends JMenu implements MapView.LayerChangeListener {
-    Action offsetAction = new JosmAction(
+    private Action offsetAction = new JosmAction(
             tr("Imagery offset"), "mapmode/adjustimg", tr("Adjust imagery offset"), null, false, false) {
         {
@@ -65,8 +65,8 @@
         }
     };
-    JMenuItem singleOffset = new JMenuItem(offsetAction);
-    JMenuItem offsetMenuItem = singleOffset;
-    Map_Rectifier_WMSmenuAction rectaction = new Map_Rectifier_WMSmenuAction();
-    int offsPos;
+    private JMenuItem singleOffset = new JMenuItem(offsetAction);
+    private JMenuItem offsetMenuItem = singleOffset;
+    private Map_Rectifier_WMSmenuAction rectaction = new Map_Rectifier_WMSmenuAction();
+    private int offsPos;
 
     public ImageryMenu() {
Index: /trunk/src/org/openstreetmap/josm/gui/MapFrame.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/MapFrame.java	(revision 5462)
+++ /trunk/src/org/openstreetmap/josm/gui/MapFrame.java	(revision 5463)
@@ -52,4 +52,5 @@
 import org.openstreetmap.josm.data.Preferences;
 import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent;
+import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener;
 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
 import org.openstreetmap.josm.gui.dialogs.ChangesetDialog;
@@ -147,14 +148,14 @@
         setLayout(new BorderLayout());
 
-        
+
         mapView = new MapView(contentPane);
 
         new FileDrop(mapView);
-        
-        leftPanel = new JPanel(); 
+
+        leftPanel = new JPanel();
         leftPanel.setLayout(new GridBagLayout());
-        
-        leftPanel.add(mapView, GBC.std().fill()); 
- 	
+
+        leftPanel.add(mapView, GBC.std().fill());
+
         // toolbar
         toolBarActions.setFloatable(false);
@@ -256,4 +257,5 @@
         MapView.removeLayerChangeListener(this);
         dialogsPanel.destroy();
+        Main.pref.removePreferenceChangeListener(sidetoolbarPreferencesChangedListener);
         for (int i = 0; i < toolBarActions.getComponentCount(); ++i) {
             if (toolBarActions.getComponent(i) instanceof Destroyable) {
@@ -431,5 +433,5 @@
         }));
 
-        Main.pref.addPreferenceChangeListener(new Preferences.PreferenceChangedListener() {
+        sidetoolbarPreferencesChangedListener = new Preferences.PreferenceChangedListener() {
 
             @Override
@@ -439,5 +441,6 @@
                 }
             }
-        });
+        };
+        Main.pref.addPreferenceChangeListener(sidetoolbarPreferencesChangedListener);
 
         if (statusLine != null && Main.pref.getBoolean("statusline.visible", true)) {
@@ -539,9 +542,9 @@
         Main.pref.putInteger("toggleDialogs.width", dialogsPanel.getWidth());
     }
-    
-     /*
+
+    /*
      * Remove panel from top of MapView by class
      */
-     public void removeTopPanel(Class<?> type) {
+    public void removeTopPanel(Class<?> type) {
         int n = leftPanel.getComponentCount();
         for (int i=0; i<n; i++) {
@@ -550,20 +553,19 @@
                 leftPanel.remove(i);
                 leftPanel.doLayout();
-//                repaint();
+                //                repaint();
                 return;
             }
         }
     }
-    
+
     /*
-    * Find panel on top of MapView by class
-    */
+     * Find panel on top of MapView by class
+     */
     public <T> T getTopPanel(Class<T> type) {
         int n = leftPanel.getComponentCount();
         for (int i=0; i<n; i++) {
             Component c = leftPanel.getComponent(i);
-            if (type.isInstance(c)) {
+            if (type.isInstance(c))
                 return type.cast(c);
-            }
         }
         return null;
@@ -590,4 +592,6 @@
      */
     private static final CopyOnWriteArrayList<MapModeChangeListener> mapModeChangeListeners = new CopyOnWriteArrayList<MapModeChangeListener>();
+
+    private PreferenceChangedListener sidetoolbarPreferencesChangedListener;
     /**
      * Adds a mapMode change listener
Index: /trunk/src/org/openstreetmap/josm/gui/SideButton.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/SideButton.java	(revision 5462)
+++ /trunk/src/org/openstreetmap/josm/gui/SideButton.java	(revision 5463)
@@ -21,8 +21,9 @@
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.tools.Destroyable;
 import org.openstreetmap.josm.tools.ImageProvider;
 import org.openstreetmap.josm.tools.Shortcut;
 
-public class SideButton extends JButton {
+public class SideButton extends JButton implements Destroyable {
     private final static int iconHeight = 20;
 
@@ -136,3 +137,12 @@
         arrowButton.addActionListener(listener);
     }
+
+    @Override
+    public void destroy() {
+        Action action = getAction();
+        if (action instanceof Destroyable) {
+            ((Destroyable) action).destroy();
+        }
+        setAction(null);
+    }
 }
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java	(revision 5462)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java	(revision 5463)
@@ -60,5 +60,4 @@
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.actions.SaveActionBase;
 import org.openstreetmap.josm.gui.ExtendedDialog;
 import org.openstreetmap.josm.gui.PleaseWaitRunnable;
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java	(revision 5462)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java	(revision 5463)
@@ -7,4 +7,5 @@
 import java.awt.BorderLayout;
 import java.awt.Component;
+import java.awt.Container;
 import java.awt.Dimension;
 import java.awt.FlowLayout;
@@ -24,4 +25,5 @@
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
+import java.beans.PropertyChangeEvent;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -48,5 +50,4 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.JosmAction;
-import org.openstreetmap.josm.data.Preferences;
 import org.openstreetmap.josm.data.preferences.ParametrizedEnumProperty;
 import org.openstreetmap.josm.gui.MainMenu;
@@ -56,4 +57,5 @@
 import org.openstreetmap.josm.gui.help.HelpUtil;
 import org.openstreetmap.josm.gui.help.Helpful;
+import org.openstreetmap.josm.tools.Destroyable;
 import org.openstreetmap.josm.tools.GBC;
 import org.openstreetmap.josm.tools.ImageProvider;
@@ -366,4 +368,17 @@
         hideNotify();
         Main.main.menu.windowMenu.remove(windowMenuItem);
+        Toolkit.getDefaultToolkit().removeAWTEventListener(this);
+        destroyComponents(this);
+    }
+
+    private void destroyComponents(Component component) {
+        if (component instanceof Container) {
+            for (Component c: ((Container)component).getComponents()) {
+                destroyComponents(c);
+            }
+        }
+        if (component instanceof Destroyable) {
+            ((Destroyable) component).destroy();
+        }
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java	(revision 5462)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java	(revision 5463)
@@ -33,4 +33,5 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.AutoScaleAction;
+import org.openstreetmap.josm.actions.ValidateAction;
 import org.openstreetmap.josm.command.Command;
 import org.openstreetmap.josm.data.SelectionChangedListener;
@@ -110,5 +111,5 @@
         tree.addTreeSelectionListener(new SelectionWatch());
         InputMapUtils.unassignCtrlShiftUpDown(tree, JComponent.WHEN_FOCUSED);
-                
+
         List<SideButton> buttons = new LinkedList<SideButton>();
 
@@ -125,9 +126,9 @@
         });
         InputMapUtils.addEnterAction(tree, selectButton.getAction());
-        
+
         selectButton.setEnabled(false);
         buttons.add(selectButton);
 
-        buttons.add(new SideButton(Main.main.validator.validateAction));
+        buttons.add(new SideButton(new ValidateAction()));
 
         fixButton = new SideButton(new AbstractAction() {
@@ -416,6 +417,6 @@
                 hasFixes = hasFixes || error.isFixable();
                 if (addSelected) {
-//                    sel.addAll(error.getPrimitives()); // was selecting already deleted primitives! see #6640
-                      sel.addAll(error.getSelectablePrimitives());
+                    //                    sel.addAll(error.getPrimitives()); // was selecting already deleted primitives! see #6640
+                    sel.addAll(error.getSelectablePrimitives());
                 }
             }
Index: /trunk/src/org/openstreetmap/josm/gui/io/LayerNameAndFilePathTableCell.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/io/LayerNameAndFilePathTableCell.java	(revision 5462)
+++ /trunk/src/org/openstreetmap/josm/gui/io/LayerNameAndFilePathTableCell.java	(revision 5463)
@@ -37,7 +37,7 @@
     private final static String ellipsis = "…" + separator;
 
-    private final static JLabel lblLayerName = new JLabel();
-    private final static JLabel lblFilename = new JLabel("");
-    private final static JTextField tfFilename = new JTextField();
+    private final JLabel lblLayerName = new JLabel();
+    private final JLabel lblFilename = new JLabel("");
+    private final JTextField tfFilename = new JTextField();
     private final JButton btnFileChooser = new JButton(new LaunchFileChooserAction());
 
@@ -66,5 +66,5 @@
                     }
                 }
-        );
+                );
         // hide border
         tfFilename.setBorder(BorderFactory.createLineBorder(getBackground()));
@@ -163,5 +163,5 @@
     /** makes the given path fit lblFilename, appends ellipsis on the left if it doesn’t fit.
      * Idea: /home/user/josm → …/user/josm → …/josm; and take the first one that fits */
-    static final private String makePathFit(String t) {
+    private String makePathFit(String t) {
         boolean hasEllipsis = false;
         while(t != null && !t.isEmpty()) {
Index: /trunk/src/org/openstreetmap/josm/gui/io/SaveLayersTableColumnModel.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/io/SaveLayersTableColumnModel.java	(revision 5462)
+++ /trunk/src/org/openstreetmap/josm/gui/io/SaveLayersTableColumnModel.java	(revision 5463)
@@ -20,7 +20,7 @@
     /** small renderer class that handles the "should be uploaded/saved" texts. */
     private static class RecommendedActionsTableCell implements TableCellRenderer {
-        private final static JPanel pnlEmpty = new JPanel();
-        private final static JLabel needsUpload = new JLabel(tr("should be uploaded"));
-        private final static JLabel needsSave = new JLabel(tr("should be saved"));
+        private final JPanel pnlEmpty = new JPanel();
+        private final JLabel needsUpload = new JLabel(tr("should be uploaded"));
+        private final JLabel needsSave = new JLabel(tr("should be saved"));
         private final static GBC defaultCellStyle = GBC.eol().fill(GBC.HORIZONTAL).insets(2, 0, 2, 0);
 
Index: /trunk/src/org/openstreetmap/josm/tools/MultikeyActionsHandler.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/MultikeyActionsHandler.java	(revision 5462)
+++ /trunk/src/org/openstreetmap/josm/tools/MultikeyActionsHandler.java	(revision 5463)
@@ -26,5 +26,4 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.tools.MultikeyShortcutAction.MultikeyInfo;
-import org.openstreetmap.josm.tools.Shortcut;
 
 public class MultikeyActionsHandler {
@@ -34,5 +33,5 @@
 
     private Map<MultikeyShortcutAction, MyAction> myActions = new HashMap<MultikeyShortcutAction,MyAction>();
-            
+
     private class MyKeyEventDispatcher implements KeyEventDispatcher {
         @Override
@@ -211,5 +210,5 @@
         }
     }
-    
+
     // unregister action and its shortcut completely
     public void removeAction(MultikeyShortcutAction action) {
@@ -217,5 +216,5 @@
         if (a!=null) {
             Main.unregisterActionShortcut(a, a.shortcut);
-            myActions.remove(a);
+            myActions.remove(action);
         }
     }
