Index: applications/editors/josm/plugins/openstreetbugs/josm-osb.launch
===================================================================
--- applications/editors/josm/plugins/openstreetbugs/josm-osb.launch	(revision 22684)
+++ applications/editors/josm/plugins/openstreetbugs/josm-osb.launch	(revision 22684)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/JOSM/src/org/openstreetmap/josm/gui/MainApplication.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JDK 6"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.openstreetmap.josm.gui.MainApplication"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="JOSM OSB"/>
+</launchConfiguration>
Index: applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/OsbPlugin.java
===================================================================
--- applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/OsbPlugin.java	(revision 22548)
+++ applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/OsbPlugin.java	(revision 22684)
@@ -79,7 +79,6 @@
             newFrame.addToggleDialog(dialog);
 
-            MapView.addLayerChangeListener(dialog);
             MapView.addLayerChangeListener(this);
-            
+
             uploadHook = new OsbUploadHook();
             UploadAction.registerUploadHook(uploadHook);
@@ -163,5 +162,5 @@
         // store the current selected node
         Node selectedNode = getDialog().getSelectedNode();
-        
+
         // determine the bounds of the currently visible area
         Bounds bounds = null;
@@ -179,5 +178,5 @@
                 // download the data
                 download.execute(dataSet, bounds);
-    
+
                 // display the parsed data
                 if(!dataSet.getNodes().isEmpty() && dialog.isDialogShowing()) {
@@ -194,5 +193,5 @@
             }
         }
-        
+
         // restore node selection
         dialog.setSelectedNode(selectedNode);
Index: applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/OsbDialog.java
===================================================================
--- applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/OsbDialog.java	(revision 22548)
+++ applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/OsbDialog.java	(revision 22684)
@@ -71,4 +71,5 @@
 import org.openstreetmap.josm.data.osm.event.TagsChangedEvent;
 import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent;
+import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
 import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
@@ -88,5 +89,5 @@
 import org.openstreetmap.josm.tools.Shortcut;
 
-public class OsbDialog extends ToggleDialog implements OsbObserver, ListSelectionListener, LayerChangeListener, 
+public class OsbDialog extends ToggleDialog implements OsbObserver, ListSelectionListener, LayerChangeListener,
 DataSetListener, SelectionChangedListener, MouseListener, OsbActionObserver {
 
@@ -106,4 +107,5 @@
     private JTabbedPane tabbedPane = new JTabbedPane();
     private boolean queuePanelVisible = false;
+    private final ActionQueue actionQueue = new ActionQueue();
 
     private boolean buttonLabels = Main.pref.getBoolean(ConfigKeys.OSB_BUTTON_LABELS);
@@ -185,5 +187,5 @@
         queuePanel = new JPanel(new BorderLayout());
         queuePanel.setName(tr("Queue"));
-        queueList = new JList(ActionQueue.getInstance());
+        queueList = new JList(getActionQueue());
         queueList.setCellRenderer(new OsbQueueListCellRenderer());
         queuePanel.add(new JScrollPane(queueList), BorderLayout.CENTER);
@@ -194,5 +196,5 @@
                 setConnectionMode(false);
                 try {
-                    ActionQueue.getInstance().processQueue();
+                    getActionQueue().processQueue();
 
                     // refresh, if the api is enabled
@@ -225,5 +227,24 @@
         closeIssueAction.addActionObserver(this);
         setConnectionMode(offline);
-        DataSet.selListeners.add(this);
+
+
+        MapView.addLayerChangeListener(this);
+    }
+
+    @Override
+    public void showNotify() {
+        DataSet.addSelectionListener(this);
+    }
+
+    @Override
+    public void hideNotify() {
+        DataSet.removeSelectionListener(this);
+    }
+
+    @Override
+    public void destroy() {
+        super.destroy();
+        MapView.removeLayerChangeListener(this);
+
     }
 
@@ -346,5 +367,5 @@
     }
 
-    private class BugComparator implements Comparator<Node> {
+    private static class BugComparator implements Comparator<Node> {
 
         public int compare(Node o1, Node o2) {
@@ -445,5 +466,5 @@
             if(osbPlugin.getLayer() != null && osbPlugin.getLayer().getDataSet() != null
                     && osbPlugin.getLayer().getDataSet().getNodes() != null
-                    && osbPlugin.getLayer().getDataSet().getNodes().contains(selectedNode)) 
+                    && osbPlugin.getLayer().getDataSet().getNodes().contains(selectedNode))
             {
                 setSelectedNode(selectedNode);
@@ -455,3 +476,7 @@
         }
     }
+
+    public ActionQueue getActionQueue() {
+        return actionQueue;
+    }
 }
Index: applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/action/ActionQueue.java
===================================================================
--- applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/action/ActionQueue.java	(revision 22548)
+++ applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/action/ActionQueue.java	(revision 22684)
@@ -7,16 +7,5 @@
 public class ActionQueue extends AbstractListModel {
 
-    private static ActionQueue instance;
-
     private LinkedList<OsbAction> queue = new LinkedList<OsbAction>();
-
-    private ActionQueue() {}
-
-    public static synchronized ActionQueue getInstance() {
-        if(instance == null) {
-            instance = new ActionQueue();
-        }
-        return instance;
-    }
 
     public boolean offer(OsbAction e) {
@@ -51,5 +40,5 @@
             // execute the action
             action.execute();
-            
+
             // notify observers
             for (OsbActionObserver obs : action.getActionObservers()) {
Index: applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/action/OsbAction.java
===================================================================
--- applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/action/OsbAction.java	(revision 22548)
+++ applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/action/OsbAction.java	(revision 22684)
@@ -49,12 +49,14 @@
 
     private List<OsbActionObserver> observers = new ArrayList<OsbActionObserver>();
-    
-    protected OsbDialog dialog;
-    
+
+    protected final OsbDialog dialog;
+
     protected boolean cancelled = false;
+    protected final ActionQueue actionQueue;
 
     public OsbAction(String name, OsbDialog osbDialog) {
         super(name);
         this.dialog = osbDialog;
+        this.actionQueue = osbDialog.getActionQueue();
     }
 
@@ -71,5 +73,5 @@
                 } else {
                     OsbAction action = clone();
-                    ActionQueue.getInstance().offer(action);
+                    actionQueue.offer(action);
                 }
             }
@@ -89,5 +91,5 @@
         observers.remove(obs);
     }
-    
+
     protected String addMesgInfo(String msg) {
         // get the user nickname
@@ -101,5 +103,5 @@
             }
         }
-        
+
         // concatenate nickname and date, if date should be included
         String info = nickname;
@@ -108,21 +110,20 @@
             DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG, Locale.getDefault());
             String date = df.format(new Date());
-            
+
             // concatenate nickname and date
             info = info.concat(", ").concat(date);
         }
-        
+
         // add user and date info to the message
-        msg = msg.concat(" [").concat(info).concat("]");
-        
-        return msg;
+        return msg.concat(" [").concat(info).concat("]");
     }
-    
+
     public List<OsbActionObserver> getActionObservers() {
         return observers;
     }
-    
+
     public abstract void execute() throws Exception;
-    
+
+    @Override
     public abstract OsbAction clone();
 }
Index: applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/action/ToggleConnectionModeAction.java
===================================================================
--- applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/action/ToggleConnectionModeAction.java	(revision 22548)
+++ applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/action/ToggleConnectionModeAction.java	(revision 22684)
@@ -16,26 +16,27 @@
 public class ToggleConnectionModeAction extends AbstractAction {
 
-    private OsbPlugin plugin;
-    
-    private OsbDialog dialog;
-    
+    private final OsbPlugin plugin;
+    private final OsbDialog dialog;
+    private final ActionQueue actionQueue;
+
     public static final String MSG_ONLINE = tr("Switch to online mode");
     public static final String MSG_OFFLINE = tr("Switch to offline mode");
-    
+
     public ToggleConnectionModeAction(OsbDialog osbDialog, OsbPlugin osbPlugin) {
         super(MSG_OFFLINE);
         this.dialog = osbDialog;
         this.plugin = osbPlugin;
+        this.actionQueue = osbDialog.getActionQueue();
     }
 
     public void actionPerformed(ActionEvent e) {
         boolean isOffline = !Main.pref.getBoolean(ConfigKeys.OSB_API_OFFLINE);
-        
+
         // inform the dialog about the connection mode
         dialog.setConnectionMode(isOffline);
-        
+
         // set the new value in the preferences
         Main.pref.put(ConfigKeys.OSB_API_OFFLINE, isOffline);
-        
+
         // toggle the tooltip text
         if(e.getSource() != null && e.getSource() instanceof JToggleButton) {
@@ -53,12 +54,12 @@
             }
         }
-        
-        
+
+
         if(!isOffline) {
-            if(ActionQueue.getInstance().getSize() == 0) {
+            if(actionQueue.getSize() == 0) {
                 dialog.hideQueuePanel();
                 return;
             }
-            
+
             // if we switch to online mode, ask if the queue should be processed
             int result = JOptionPane.showConfirmDialog(Main.parent,
@@ -68,9 +69,9 @@
             if(result == JOptionPane.YES_OPTION) {
                 try {
-                    ActionQueue.getInstance().processQueue();
-                    
+                    actionQueue.processQueue();
+
                     // toggle queue panel visibility, if now error occured
                     dialog.hideQueuePanel();
-    
+
                     // refresh, if the api is enabled
                     if(!Main.pref.getBoolean(ConfigKeys.OSB_API_DISABLED)) {
