Index: applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/FixAddressesPlugin.java
===================================================================
--- applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/FixAddressesPlugin.java	(revision 28623)
+++ applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/FixAddressesPlugin.java	(revision 28624)
@@ -27,5 +27,4 @@
  */
 public class FixAddressesPlugin extends Plugin {
-	private static IncompleteAddressesDialog incompleteAddrDlg;
 	private static FixAddressesPreferences preferences;
 
@@ -55,13 +54,9 @@
 	@Override
 	public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
-		// TODO Auto-generated method stub
-		super.mapFrameInitialized(oldFrame, newFrame);
-
 		if (newFrame != null) {
-			incompleteAddrDlg = new IncompleteAddressesDialog();
 			FixAddressesMapMode faMode = new FixAddressesMapMode(Main.map);
 			IconToggleButton faModeButton = new IconToggleButton(faMode);
 			faModeButton.setVisible(true);
-			newFrame.addToggleDialog(incompleteAddrDlg);
+			newFrame.addToggleDialog(new IncompleteAddressesDialog());
 		}
 	}
@@ -71,11 +66,4 @@
 		// TODO Auto-generated method stub
 		return getPreferences();
-	}
-
-	/**
-	 * @return the incompleteAddrDlg
-	 */
-	protected static IncompleteAddressesDialog getIncompleteAddrDlg() {
-		return incompleteAddrDlg;
 	}
 
Index: applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysAction.java
===================================================================
--- applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysAction.java	(revision 28623)
+++ applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysAction.java	(revision 28624)
@@ -58,5 +58,5 @@
 
                     AlignWaysCmdKeepLength cmdAW;
-                    if (AlignWaysPlugin.awDialog.getAwOpt() == AligningModeOption.ALGN_OPT_KEEP_ANGLE) {
+                    if (AlignWaysPlugin.getAwDialog().getAwOpt() == AligningModeOption.ALGN_OPT_KEEP_ANGLE) {
                         cmdAW = new AlignWaysCmdKeepAngles();
                     } else {
Index: applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysDialog.java
===================================================================
--- applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysDialog.java	(revision 28623)
+++ applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysDialog.java	(revision 28624)
@@ -163,9 +163,3 @@
 
     }
-
-    public JCheckBoxMenuItem getWindowMenuItem() {
-        return windowMenuItem;
-    }
-
-
 }
Index: applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysPlugin.java
===================================================================
--- applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysPlugin.java	(revision 28623)
+++ applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysPlugin.java	(revision 28624)
@@ -2,6 +2,4 @@
 
 import static org.openstreetmap.josm.tools.I18n.tr;
-
-import javax.swing.JMenuItem;
 
 import org.openstreetmap.josm.Main;
@@ -20,10 +18,9 @@
 public class AlignWaysPlugin extends Plugin {
 
-    static AlignWaysMode awMode;
-    private final IconToggleButton btn;
-    static JMenuItem alignWaysMenuItem;
-    static JosmAction awAction;
-    static AlignWaysDialog awDialog;
-    static IconToggleButton optBtn;
+    private static AlignWaysMode awMode;
+    private static IconToggleButton btn;
+    private static JosmAction awAction;
+    private static AlignWaysDialog awDialog;
+    private static IconToggleButton optBtn;
 
     // The major version is e.g. used to decide when to trigger What's New windows
@@ -33,32 +30,24 @@
         super(info);
         
-        // Construct the AlignWays mode toggle button
-        awMode = new AlignWaysMode(Main.map, "alignways", tr("Align Ways mode"));
-        btn = new IconToggleButton(awMode);
-        btn.setVisible(true);
-        
         // Add the action entries to the Tools Menu
         Main.main.menu.toolsMenu.addSeparator();
         awAction = new AlignWaysAction();
-        alignWaysMenuItem = MainMenu.add(Main.main.menu.toolsMenu, awAction);
-        
-        awDialog = new AlignWaysDialog(awMode);
-        // Prevent user clicking on the Windows menu entry while panel is meaningless
-        awDialog.getWindowMenuItem().setEnabled(false);
+        MainMenu.add(Main.main.menu.toolsMenu, awAction);
     }
 
     @Override
     public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
-        if(newFrame != null) {
-            optBtn = newFrame.addToggleDialog(AlignWaysPlugin.getAwDialog());
+        if (newFrame != null) {
+            // Construct the AlignWays mode toggle button
+            awMode = new AlignWaysMode(Main.map, "alignways", tr("Align Ways mode"));
+            btn = new IconToggleButton(awMode);
+            btn.setVisible(true);
+            newFrame.addMapMode(btn);
+            optBtn = newFrame.addToggleDialog(awDialog = new AlignWaysDialog(awMode));
         } else {
-            // Disable menu item in Windows menu
-            awDialog.getWindowMenuItem().setEnabled(false);
-        }
-
-        if (Main.map != null) {
-            Main.map.addMapMode(btn);
-            // Re-enable menu item in Windows menu
-            awDialog.getWindowMenuItem().setEnabled(true);
+            awDialog = null;
+            optBtn = null;
+            btn = null;
+            awMode = null;
         }
     }
@@ -91,4 +80,3 @@
         return optBtn;
     }
-
 }
Index: applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysTipsPanel.java
===================================================================
--- applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysTipsPanel.java	(revision 28623)
+++ applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysTipsPanel.java	(revision 28624)
@@ -101,5 +101,5 @@
         step04.setText(tr("<html>\n<div style=\"font-family:sans-serif\">\n<ul>\n  <li><b>Align the segments.</b> Press <b><i><span style=\"color:green\">{0}"
                 + "</span></i></b>. Alternatively you''ll find the command in the <b>Tools</b>\n menu or may want to place the action on the <b>toolbar</b>.\n  </li>\n</ul>\n</div>\n</html>\n\n",
-                AlignWaysPlugin.awAction.getShortcut().getKeyText()));
+                AlignWaysPlugin.getAwAction().getShortcut().getKeyText()));
         step04.setVerticalAlignment(SwingConstants.TOP);
 
Index: applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementDialog.java
===================================================================
--- applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementDialog.java	(revision 28623)
+++ applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementDialog.java	(revision 28624)
@@ -32,5 +32,5 @@
  * @author ramack
  */
-public class MeasurementDialog extends ToggleDialog {
+public class MeasurementDialog extends ToggleDialog implements SelectionChangedListener {
     private static final long serialVersionUID = 4708541586297950021L;
 
@@ -59,5 +59,5 @@
      */
     protected JLabel segAngleLabel;
-
+    
     /**
      * Constructor
@@ -112,50 +112,6 @@
             resetButton
         }));
-
-        final MeasurementDialog dlg = this;
-
-        DataSet.addSelectionListener(new SelectionChangedListener() {
-            @Override
-            public void selectionChanged(Collection<? extends OsmPrimitive> arg0) {
-                double length = 0.0;
-                double segAngle = 0.0;
-                double area = 0.0;
-                Node lastNode = null;
-                for(OsmPrimitive p:arg0) {
-                    // ignore incomplete nodes
-                    if(p instanceof Node && !((Node)p).isIncomplete()) {
-                        Node n =(Node)p;
-                        if(lastNode == null) {
-                            lastNode = n;
-                        } else {
-                            length += lastNode.getCoor().greatCircleDistance(n.getCoor());
-                            segAngle = MeasurementLayer.angleBetween(lastNode.getCoor(), n.getCoor());
-                            lastNode = n;
-                        }
-                    } else if (p instanceof Way) {
-                        Way w = (Way)p;
-                        Node lastN = null;
-                        for (Node n: w.getNodes()) {
-                            if (lastN != null && lastN.getCoor() != null && n.getCoor() != null) {
-                                length += lastN.getCoor().greatCircleDistance(n.getCoor());
-                                //http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/
-                                area += (MeasurementLayer.calcX(n.getCoor()) * MeasurementLayer.calcY(lastN.getCoor()))
-                                - (MeasurementLayer.calcY(n.getCoor()) * MeasurementLayer.calcX(lastN.getCoor()));
-                                segAngle = MeasurementLayer.angleBetween(lastN.getCoor(), n.getCoor());
-                            }
-                            lastN = n;
-                        }
-                        if (lastN != null && lastN == w.getNodes().iterator().next())
-                            area = Math.abs(area / 2);
-                        else
-                            area = 0;
-                    }
-                }
-                dlg.selectLengthLabel.setText(new DecimalFormat("#0.00").format(length) + " m");
-
-                dlg.segAngleLabel.setText(new DecimalFormat("#0.0").format(segAngle) + " \u00b0");
-                dlg.selectAreaLabel.setText(new DecimalFormat("#0.00").format(area) + " m\u00b2");
-            }
-        });
+        
+        DataSet.addSelectionListener(this);
     }
 
@@ -166,3 +122,53 @@
         MeasurementPlugin.getCurrentLayer().reset();
     }
+
+	@Override
+	public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
+        double length = 0.0;
+        double segAngle = 0.0;
+        double area = 0.0;
+        Node lastNode = null;
+        for (OsmPrimitive p : newSelection) {
+            // ignore incomplete nodes
+            if (p instanceof Node && !((Node)p).isIncomplete()) {
+                Node n =(Node)p;
+                if (lastNode == null) {
+                    lastNode = n;
+                } else {
+                    length += lastNode.getCoor().greatCircleDistance(n.getCoor());
+                    segAngle = MeasurementLayer.angleBetween(lastNode.getCoor(), n.getCoor());
+                    lastNode = n;
+                }
+            } else if (p instanceof Way) {
+                Way w = (Way)p;
+                Node lastN = null;
+                for (Node n: w.getNodes()) {
+                    if (lastN != null && lastN.getCoor() != null && n.getCoor() != null) {
+                        length += lastN.getCoor().greatCircleDistance(n.getCoor());
+                        //http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/
+                        area += (MeasurementLayer.calcX(n.getCoor()) * MeasurementLayer.calcY(lastN.getCoor()))
+                        - (MeasurementLayer.calcY(n.getCoor()) * MeasurementLayer.calcX(lastN.getCoor()));
+                        segAngle = MeasurementLayer.angleBetween(lastN.getCoor(), n.getCoor());
+                    }
+                    lastN = n;
+                }
+                if (lastN != null && lastN == w.getNodes().iterator().next())
+                    area = Math.abs(area / 2);
+                else
+                    area = 0;
+            }
+        }
+        selectLengthLabel.setText(new DecimalFormat("#0.00").format(length) + " m");
+        segAngleLabel.setText(new DecimalFormat("#0.0").format(segAngle) + " \u00b0");
+        selectAreaLabel.setText(new DecimalFormat("#0.00").format(area) + " m\u00b2");
+	}
+
+	/* (non-Javadoc)
+	 * @see org.openstreetmap.josm.gui.dialogs.ToggleDialog#destroy()
+	 */
+	@Override
+	public void destroy() {
+		super.destroy();
+		DataSet.removeSelectionListener(this);
+	}
 }
Index: applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementLayer.java
===================================================================
--- applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementLayer.java	(revision 28623)
+++ applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementLayer.java	(revision 28624)
@@ -141,5 +141,7 @@
         DecimalFormat nf = new DecimalFormat("#0.00");
         DecimalFormat nf2 = new DecimalFormat("#0.0");
-        MeasurementPlugin.measurementDialog.pathLengthLabel.setText(pathLength < 800?nf2.format(pathLength) + " m":nf.format(pathLength/1000) + " km");
+        if (MeasurementPlugin.measurementDialog != null) { 
+            MeasurementPlugin.measurementDialog.pathLengthLabel.setText(pathLength < 800?nf2.format(pathLength) + " m":nf.format(pathLength/1000) + " km");
+        }
     }
 
Index: applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementPlugin.java
===================================================================
--- applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementPlugin.java	(revision 28623)
+++ applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementPlugin.java	(revision 28624)
@@ -21,20 +21,23 @@
     public MeasurementPlugin(PluginInformation info) {
         super(info);
-        mode = new MeasurementMode(Main.map, "measurement", tr("measurement mode"));
-        btn = new IconToggleButton(mode);
-        btn.setVisible(true);
-        measurementDialog = new MeasurementDialog();
     }
 
     @Override
     public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
-        if(newFrame != null)
-            newFrame.addToggleDialog(measurementDialog);
-        if(Main.map != null)
-            Main.map.addMapMode(btn);
+        if (newFrame != null) {
+            newFrame.addToggleDialog(measurementDialog = new MeasurementDialog());
+            mode = new MeasurementMode(newFrame, "measurement", tr("measurement mode"));
+            btn = new IconToggleButton(mode);
+            btn.setVisible(true);
+            newFrame.addMapMode(btn);
+        } else {
+        	btn = null;
+        	mode = null;
+        	measurementDialog = null;
+        }
     }
 
-    public static MeasurementLayer getCurrentLayer(){
-        if(currentLayer == null){
+    public static MeasurementLayer getCurrentLayer() {
+        if (currentLayer == null) {
             currentLayer = new MeasurementLayer(tr("Measurements"));
             Main.main.addLayer(currentLayer);
Index: applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingPlugin.java
===================================================================
--- applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingPlugin.java	(revision 28623)
+++ applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingPlugin.java	(revision 28624)
@@ -79,5 +79,5 @@
 	 * The side dialog where nodes are listed
 	 */
-	private final RoutingDialog routingDialog;
+	private RoutingDialog routingDialog;
 
 	/**
@@ -147,6 +147,4 @@
 		logger.debug("Loading routing plugin...");
 		preferenceSettings=new RoutingPreferenceDialog();
-		// Create side dialog
-		routingDialog = new RoutingDialog();
 		// Initialize layers list
 		layers = new ArrayList<RoutingLayer>();
@@ -188,5 +186,5 @@
 	@Override
 	public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
-		if(newFrame != null) {
+		if (newFrame != null) {
 			// Create plugin map modes
 			addRouteNodeAction = new AddRouteNodeAction(newFrame);
@@ -205,5 +203,13 @@
 			// Enable menu
 			menu.enableStartItem();
-			newFrame.addToggleDialog(routingDialog);
+			newFrame.addToggleDialog(routingDialog = new RoutingDialog());
+		} else {
+			addRouteNodeAction = null;
+			removeRouteNodeAction = null;
+			moveRouteNodeAction = null;
+			addRouteNodeButton = null;
+			removeRouteNodeButton = null;
+			moveRouteNodeButton = null;
+			routingDialog = null;
 		}
 	}
@@ -216,9 +222,13 @@
 		if (newLayer instanceof RoutingLayer) {			/*   show Routing toolbar and dialog window  */
 			menu.enableRestOfItems();
-			routingDialog.showDialog();
-			routingDialog.refresh();
+			if (routingDialog != null) {
+				routingDialog.showDialog();
+				routingDialog.refresh();
+			}
 		}else{											/*   hide Routing toolbar and dialog window  */
 			menu.disableRestOfItems();
-			routingDialog.hideDialog();
+			if (routingDialog != null) {
+				routingDialog.hideDialog();
+			}
 		}
 	}
@@ -267,5 +277,7 @@
 		}
 		// Reload RoutingDialog table model
-		routingDialog.refresh();
+		if (routingDialog != null) {
+			routingDialog.refresh();
+		}
 	}
 
Index: applications/editors/josm/plugins/turnlanes/src/org/openstreetmap/josm/plugins/turnlanes/gui/TurnLanesDialog.java
===================================================================
--- applications/editors/josm/plugins/turnlanes/src/org/openstreetmap/josm/plugins/turnlanes/gui/TurnLanesDialog.java	(revision 28623)
+++ applications/editors/josm/plugins/turnlanes/src/org/openstreetmap/josm/plugins/turnlanes/gui/TurnLanesDialog.java	(revision 28624)
@@ -129,6 +129,6 @@
     };
     
-    private final Action editAction = new EditAction();
-    private final Action validateAction = new ValidateAction();
+    private final JosmAction editAction = new EditAction();
+    private final JosmAction validateAction = new ValidateAction();
     
     private static final long serialVersionUID = -1998375221636611358L;
@@ -220,4 +220,6 @@
         MapView.removeEditLayerChangeListener(this);
         DataSet.removeSelectionListener(this);
+        editAction.destroy();
+        validateAction.destroy();
 	}
 }
Index: applications/editors/josm/plugins/waypoint_search/src/org/openstreetmap/josm/plugins/waypointSearch/WaypointSearchPlugin.java
===================================================================
--- applications/editors/josm/plugins/waypoint_search/src/org/openstreetmap/josm/plugins/waypointSearch/WaypointSearchPlugin.java	(revision 28623)
+++ applications/editors/josm/plugins/waypoint_search/src/org/openstreetmap/josm/plugins/waypointSearch/WaypointSearchPlugin.java	(revision 28624)
@@ -1,11 +1,12 @@
 package org.openstreetmap.josm.plugins.waypointSearch;
 
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import org.openstreetmap.josm.gui.MapFrame;
+import org.openstreetmap.josm.gui.MapView;
+import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
+import org.openstreetmap.josm.gui.layer.Layer;
 import org.openstreetmap.josm.plugins.Plugin;
 import org.openstreetmap.josm.plugins.PluginInformation;
-import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.gui.MapView;
-import org.openstreetmap.josm.gui.layer.Layer;
-import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
-import static org.openstreetmap.josm.tools.I18n.tr;
 
 public class WaypointSearchPlugin extends Plugin implements LayerChangeListener  {
@@ -15,6 +16,6 @@
     * @param info  information about the plugin and its local installation    
     */
-    private Engine engine = new Engine();
-    private SelectWaypointDialog waypointDialog = new SelectWaypointDialog(tr("Waypoint search"), "ToolbarIcon", tr("Search after waypoint. Click and move the map view to the waypoint."), null, 100);
+    private final Engine engine = new Engine();
+    private SelectWaypointDialog waypointDialog;
     
     public WaypointSearchPlugin(PluginInformation info) {
@@ -23,62 +24,31 @@
     }
      
-    @Override
+	@Override
+	public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
+		if (newFrame != null) {
+			newFrame.addToggleDialog(waypointDialog = new SelectWaypointDialog(
+					tr("Waypoint search"), "ToolbarIcon", tr("Search after waypoint. Click and move the map view to the waypoint."), null, 100));
+		} else {
+			waypointDialog = null;
+		}
+	}
+
+	@Override
     public void activeLayerChange(Layer oldLayer, Layer newLayer) {
-        // TODO Auto-generated method stub
-        
     }
-
     
     @Override
     public void layerAdded(Layer newLayer) {
-        //add dialog
-        if (Main.map.getToggleDialog(SelectWaypointDialog.class)==null) {
-            Main.map.addToggleDialog(waypointDialog);
-        }
-        //update search
-        if (engine.gpxLayersExist()) {
+        // update search
+        if (waypointDialog != null && engine.gpxLayersExist()) {
             waypointDialog.updateSearchResults();
         }
     }
 
-
-
     @Override
     public void layerRemoved(Layer oldLayer) {
-        if (!engine.gpxLayersExist()) {
+        if (waypointDialog != null && !engine.gpxLayersExist()) {
             waypointDialog.updateSearchResults();
         }   
     }
- 
 }
-
-
-
-    
-    
-    
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-    
-    
-
-
-
-
-
-
