Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingGraph.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingGraph.java	(revision 14403)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingGraph.java	(revision 14404)
@@ -38,5 +38,5 @@
 import org.jgrapht.graph.AsUndirectedGraph;
 import org.jgrapht.graph.DirectedWeightedMultigraph;
-import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.Way;
@@ -74,4 +74,9 @@
 	private RouteType routeType;
 
+    /**
+     * Associated Osm DataSet
+     */
+	private DataSet data;
+
 	/**
 	 * Logger.
@@ -101,7 +106,8 @@
 	 * Default Constructor.
 	 */
-	public RoutingGraph() {
+	public RoutingGraph(DataSet data) {
 		this.graphState = false;
 		this.graph = null;
+		this.data = data;
 		routeType=RouteType.SHORTEST;
 		routingProfile=new RoutingProfile("default");
@@ -118,9 +124,9 @@
 	public void createGraph() {
 
-		logger.debug("Init Create Graph");
+		logger.debug("Creating Graph...");
 		graph = new DirectedWeightedMultigraph<Node, OsmEdge>(OsmEdge.class);
 
 		// iterate all ways and segments for all nodes:
-		for (Way way : Main.ds.ways) {
+		for (Way way : data.ways) {
 			if (way != null && !way.deleted && this.isvalidWay(way)) {
 				Node from = null;
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingLayer.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingLayer.java	(revision 14403)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingLayer.java	(revision 14404)
@@ -37,5 +37,7 @@
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.LinkedList;
 import java.util.List;
+import java.util.TreeMap;
 
 import javax.swing.Icon;
@@ -47,9 +49,13 @@
 import org.openstreetmap.josm.actions.RenameLayerAction;
 import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.data.osm.WaySegment;
 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
 import org.openstreetmap.josm.gui.MapView;
+import org.openstreetmap.josm.gui.NavigatableComponent;
 import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
 import org.openstreetmap.josm.gui.dialogs.LayerListPopup;
 import org.openstreetmap.josm.gui.layer.Layer;
+import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 import org.openstreetmap.josm.tools.ColorHelper;
 import org.openstreetmap.josm.tools.ImageProvider;
@@ -82,12 +88,17 @@
 
     /**
-     * Icon Start Middle End
+     * Start, Middle and End icons
      */
     private Icon startIcon,middleIcon,endIcon;
 
     /**
-     * Flag that manager activation layer
-     */
-    private boolean layerAdded = false;
+     * Associated OSM layer
+     */
+    private OsmDataLayer dataLayer;
+
+//    /**
+//     * Flag that manager activation layer
+//     */
+//    private boolean layerAdded = false;
 
     /**
@@ -95,12 +106,13 @@
      * @param name Layer name.
      */
-	public RoutingLayer(String name) {
+	public RoutingLayer(String name, OsmDataLayer dataLayer) {
 		super(name);
-		logger.debug("Init Routing Layer");
+		logger.debug("Creating Routing Layer...");
         if(startIcon == null) startIcon = ImageProvider.get("routing", "startflag");
         if(middleIcon == null) middleIcon = ImageProvider.get("routing", "middleflag");
         if(endIcon == null) endIcon = ImageProvider.get("routing", "endflag");
-        this.routingModel = new RoutingModel();
-        logger.debug("End init Routing Layer");
+        this.dataLayer = dataLayer;
+        this.routingModel = new RoutingModel(dataLayer.data);
+        logger.debug("Routing Layer created.");
 	}
 
@@ -114,18 +126,52 @@
 
 	/**
-	 * Check if layer is load.
-	 * @return <code>true</code> Layer load.
-	 *         <code>false</code> Layer don't load.
-	 */
-	public boolean isLayerAdded() {
-		return layerAdded;
+	 * Gets associated data layer
+	 * @return OsmDataLayer associated to the RoutingLayer
+	 */
+	public OsmDataLayer getDataLayer() {
+		return dataLayer;
 	}
 
 	/**
-	 * Setter layer active.
-	 */
-	public void setLayerAdded() {
-		layerAdded = true;
-	}
+	 * Gets nearest node belonging to a highway tagged way
+	 * @param p Point on the screen
+	 * @return The nearest highway node, in the range of the snap distance
+	 */
+    public final Node getNearestHighwayNode(Point p) {
+    	Node nearest = null;
+    	double minDist = 0;
+        for (Way w : dataLayer.data.ways) {
+            if (w.deleted || w.incomplete || w.get("highway")==null) continue;
+            for (Node n : w.nodes) {
+                if (n.deleted || n.incomplete) continue;
+
+                Point P = Main.map.mapView.getPoint(n.eastNorth);
+                double dist = p.distanceSq(P);
+                if (dist < NavigatableComponent.snapDistance) {
+                	if ((nearest == null) || (dist < minDist)) {
+                		nearest = n;
+                		minDist = dist;
+                	}
+                }
+            }
+        }
+        return nearest;
+    }
+
+//	/**
+//	 * Check if layer is load.
+//	 * @return <code>true</code> Layer load.
+//	 *         <code>false</code> Layer don't load.
+//	 */
+//	public boolean isLayerAdded() {
+//		return layerAdded;
+//	}
+//
+//	/**
+//	 * Setter layer active.
+//	 */
+//	public void setLayerAdded() {
+//		layerAdded = true;
+//	}
 
 	/*
@@ -283,5 +329,5 @@
     public void destroy() {
 		routingModel.reset();
-		layerAdded = false;
+//		layerAdded = false;
 	}
 
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingModel.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingModel.java	(revision 14403)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingModel.java	(revision 14404)
@@ -32,4 +32,5 @@
 
 import org.apache.log4j.Logger;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
 
@@ -70,7 +71,7 @@
      * Default Constructor.
      */
-	public RoutingModel() {
+	public RoutingModel(DataSet data) {
         nodes = new ArrayList<Node>();
-        routingGraph = new RoutingGraph();
+        routingGraph = new RoutingGraph(data);
 	}
 
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 14403)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingPlugin.java	(revision 14404)
@@ -33,4 +33,7 @@
 
 import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
 
 import org.apache.log4j.Logger;
@@ -40,4 +43,5 @@
 import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.layer.Layer;
+import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;
 import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
@@ -65,9 +69,8 @@
 	static Logger logger = Logger.getLogger(RoutingPlugin.class);
 
-	/**
-	 * Displays the layer menu when right clicking on the layer name, and manages
-	 * how to paint the layer.
-	 */
-    private RoutingLayer routingLayer;
+    /**
+     * The list of routing layers
+     */
+    private ArrayList<RoutingLayer> layers;
 
     /**
@@ -136,6 +139,6 @@
 		// Create side dialog
 		routingDialog = new RoutingDialog();
-        // Add routing layer
-        routingLayer = new RoutingLayer(tr("Navigation"));
+		// Initialize layers list
+		layers = new ArrayList<RoutingLayer>();
         // Add menu
         menu = new RoutingMenu(tr("Routing"));
@@ -155,12 +158,4 @@
 
 	/**
-	 * Get the routing layer
-	 * @return The instance of the routing layer
-	 */
-	public RoutingLayer getRoutingLayer() {
-		return routingLayer;
-	}
-
-	/**
 	 * Get the routing side dialog
 	 * @return The instance of the routing side dialog
@@ -168,4 +163,11 @@
 	public RoutingDialog getRoutingDialog() {
 		return routingDialog;
+	}
+
+	public void addLayer() {
+		OsmDataLayer osmLayer = Main.main.editLayer();
+		RoutingLayer layer = new RoutingLayer(tr("Routing") + " [" + osmLayer.name + "]", osmLayer);
+		layers.add(layer);
+		Main.main.addLayer(layer);
 	}
 
@@ -181,5 +183,5 @@
         	removeRouteNodeAction = new RemoveRouteNodeAction(newFrame);
         	moveRouteNodeAction = new MoveRouteNodeAction(newFrame);
-        	// Create plugin buttons and add them to the tool bar
+        	// Create plugin buttons and add them to the toolbar
         	addRouteNodeButton = new IconToggleButton(addRouteNodeAction);
         	removeRouteNodeButton = new IconToggleButton(removeRouteNodeAction);
@@ -205,5 +207,7 @@
      * @see org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener#activeLayerChange(org.openstreetmap.josm.gui.layer.Layer, org.openstreetmap.josm.gui.layer.Layer)
      */
-	public void activeLayerChange(Layer oldLayer, Layer newLayer) {}
+	public void activeLayerChange(Layer oldLayer, Layer newLayer) {
+		routingDialog.refresh();
+	}
 
 	/*
@@ -214,9 +218,12 @@
 		// Add button(s) to the tool bar when the routing layer is added
 		if (newLayer instanceof RoutingLayer) {
-			newLayer.name=tr("Routing")+" ["+Main.map.mapView.getActiveLayer().name+"]";
 			addRouteNodeButton.setVisible(true);
 			removeRouteNodeButton.setVisible(true);
 			moveRouteNodeButton.setVisible(true);
 			menu.enableRestOfItems();
+			// Set layer on top and select layer, also refresh toggleDialog to reflect selection
+			Main.map.mapView.moveLayer(newLayer, 0);
+//			Main.map.mapView.setActiveLayer(newLayer);
+//			Main.map.toggleDialogs.repaint();
 			logger.debug("Added routing layer.");
 		}
@@ -228,12 +235,31 @@
 	 */
 	public void layerRemoved(Layer oldLayer) {
-		// Remove button(s) from the tool bar when the routing layer is removed
-		if (oldLayer instanceof RoutingLayer) {
+		if ((oldLayer instanceof RoutingLayer) & (layers.size()==1)) {
+			// Remove button(s) from the tool bar when the last routing layer is removed
 			addRouteNodeButton.setVisible(false);
 			removeRouteNodeButton.setVisible(false);
 			moveRouteNodeButton.setVisible(false);
 			menu.disableRestOfItems();
+			layers.remove(oldLayer);
     		logger.debug("Removed routing layer.");
+		} else if (oldLayer instanceof OsmDataLayer) {
+			// Remove all associated routing layers
+			// Convert to Array to prevent ConcurrentModificationException when removing layers from ArrayList
+			// FIXME: can't remove associated routing layers without triggering exceptions in some cases
+			RoutingLayer[] layersArray = layers.toArray(new RoutingLayer[0]);
+			for (int i=0;i<layersArray.length;i++) {
+				if (layersArray[i].getDataLayer().equals(oldLayer)) {
+					// Move layer to the top
+					Main.map.mapView.moveLayer(layersArray[i], 0);
+					try {
+						// Remove layer
+						Main.map.mapView.removeLayer(layersArray[i]);
+					} catch (IllegalArgumentException e) {
+					}
+				}
+			}
 		}
+		// Reload RoutingDialog table model
+		routingDialog.refresh();
 	}
 
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/AddRouteNodeAction.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/AddRouteNodeAction.java	(revision 14403)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/AddRouteNodeAction.java	(revision 14404)
@@ -31,5 +31,4 @@
 
 import java.awt.event.MouseEvent;
-import java.util.List;
 
 import org.apache.log4j.Logger;
@@ -37,10 +36,8 @@
 import org.openstreetmap.josm.actions.mapmode.MapMode;
 import org.openstreetmap.josm.data.osm.Node;
-import org.openstreetmap.josm.data.osm.WaySegment;
 import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.tools.ImageProvider;
 
 import com.innovant.josm.plugin.routing.RoutingLayer;
-import com.innovant.josm.plugin.routing.RoutingModel;
 import com.innovant.josm.plugin.routing.RoutingPlugin;
 import com.innovant.josm.plugin.routing.gui.RoutingDialog;
@@ -62,12 +59,4 @@
 	 */
 	static Logger logger = Logger.getLogger(AddRouteNodeAction.class);
-    /**
-     * Routing Model.
-     */
-	private RoutingModel routingModel;
-	/**
-	 * Routing Layer.
-	 */
-    private RoutingLayer routingLayer;
 	/**
 	 * Routing Dialog.
@@ -84,6 +73,4 @@
 				tr("Click to add route nodes."),
 				mapFrame, ImageProvider.getCursor("crosshair", null));
-        this.routingLayer = RoutingPlugin.getInstance().getRoutingLayer();
-        this.routingModel = routingLayer.getRoutingModel();
         this.routingDialog = RoutingPlugin.getInstance().getRoutingDialog();
 	}
@@ -104,27 +91,15 @@
         	// Search for nearest highway node
         	Node node = null;
-        	List<WaySegment> wsl = Main.map.mapView.getNearestWaySegments(e.getPoint());
-        	for (WaySegment ws:wsl) {
-        		if (ws.way.get("highway")!=null) {
-        			// If waysegment belongs to a highway compare the distance from
-        			// both waysegment nodes to the point clicked and keep the nearest one
-        			Node node0 = ws.way.nodes.get(ws.lowerIndex);
-        			Node node1 = ws.way.nodes.get(ws.lowerIndex + 1);
-        			double d0 = Main.map.mapView.getPoint(node0.eastNorth).distanceSq(e.getPoint());
-        			double d1 = Main.map.mapView.getPoint(node1.eastNorth).distanceSq(e.getPoint());
-        			if (d0<d1)
-        				node = node0;
-        			else
-        				node = node1;
-        			break;
-        		}
+        	if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
+        		RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+        		node = layer.getNearestHighwayNode(e.getPoint());
+                if(node == null) {
+                	logger.debug("no selected node");
+                    return;
+                }
+                logger.debug("selected node " + node);
+                layer.getRoutingModel().addNode(node);
+                routingDialog.addNode(node);
         	}
-            logger.debug("selected node " + node);
-            if(node == null) {
-            	logger.debug("no selected node");
-                return;
-            }
-            routingModel.addNode(node);
-            routingDialog.addNode(node.id+" ["+node.coor.toDisplayString()+"]");
         }
         Main.map.repaint();
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/MoveRouteNodeAction.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/MoveRouteNodeAction.java	(revision 14403)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/MoveRouteNodeAction.java	(revision 14404)
@@ -38,5 +38,4 @@
 import org.openstreetmap.josm.actions.mapmode.MapMode;
 import org.openstreetmap.josm.data.osm.Node;
-import org.openstreetmap.josm.data.osm.WaySegment;
 import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.tools.ImageProvider;
@@ -71,14 +70,4 @@
 
 	/**
-     * Routing Model.
-     */
-	private RoutingModel routingModel;
-
-	/**
-	 * Routing Layer.
-	 */
-    private RoutingLayer routingLayer;
-
-	/**
 	 * Routing Dialog.
 	 */
@@ -99,6 +88,4 @@
 				tr("Click and drag to move route nodes."),
 				mapFrame, ImageProvider.getCursor("normal", "move"));
-        this.routingLayer = RoutingPlugin.getInstance().getRoutingLayer();
-        this.routingModel = routingLayer.getRoutingModel();
         this.routingDialog = RoutingPlugin.getInstance().getRoutingDialog();
 	}
@@ -117,18 +104,22 @@
         // If left button is pressed
         if (e.getButton() == MouseEvent.BUTTON1) {
-        	// Search for the nearest node in the list
-        	List<Node> nl = routingModel.getSelectedNodes();
-        	index = -1;
-        	double dmax = DRAG_SQR_RADIUS; // maximum distance, in pixels
-           	for (int i=0;i<nl.size();i++) {
-           		Node node = nl.get(i);
-        		double d = Main.map.mapView.getPoint(node.eastNorth).distanceSq(e.getPoint());
-        		if (d < dmax) {
-        			dmax = d;
-        			index = i;
-        		}
+        	if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
+        		RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+        		RoutingModel routingModel = layer.getRoutingModel();
+            	// Search for the nearest node in the list
+            	List<Node> nl = routingModel.getSelectedNodes();
+            	index = -1;
+            	double dmax = DRAG_SQR_RADIUS; // maximum distance, in pixels
+               	for (int i=0;i<nl.size();i++) {
+               		Node node = nl.get(i);
+            		double d = Main.map.mapView.getPoint(node.eastNorth).distanceSq(e.getPoint());
+            		if (d < dmax) {
+            			dmax = d;
+            			index = i;
+            		}
+            	}
+               	if (index>=0)
+                    logger.debug("Moved from node " + nl.get(index));
         	}
-           	if (index>=0)
-                logger.debug("Moved from node " + nl.get(index));
         }
     }
@@ -145,32 +136,21 @@
 
     private void searchAndReplaceNode(Point point) {
-    	// Search for nearest highway node
-    	Node node = null;
-    	List<WaySegment> wsl = Main.map.mapView.getNearestWaySegments(point);
-    	for (WaySegment ws:wsl) {
-    		if (ws.way.get("highway")!=null) {
-    			// If waysegment belongs to a highway compare the distance from
-    			// both waysegment nodes to the point clicked and keep the nearest one
-    			Node node0 = ws.way.nodes.get(ws.lowerIndex);
-    			Node node1 = ws.way.nodes.get(ws.lowerIndex + 1);
-    			double d0 = Main.map.mapView.getPoint(node0.eastNorth).distanceSq(point);
-    			double d1 = Main.map.mapView.getPoint(node1.eastNorth).distanceSq(point);
-    			if (d0<d1)
-    				node = node0;
-    			else
-    				node = node1;
-    			break;
-    		}
+    	if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
+    		RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+    		RoutingModel routingModel = layer.getRoutingModel();
+        	// Search for nearest highway node
+        	Node node = null;
+    		node = layer.getNearestHighwayNode(point);
+            if (node == null) {
+            	logger.debug("Didn't found a close node to move to.");
+                return;
+            }
+            logger.debug("Moved to node " + node);
+            routingModel.removeNode(index);
+    		routingDialog.removeNode(index);
+            routingModel.insertNode(index, node);
+    		routingDialog.insertNode(index, node);
+            Main.map.repaint();
     	}
-        if (node == null) {
-        	logger.debug("Didn't found a close node to move to.");
-            return;
-        }
-        logger.debug("Moved to node " + node);
-        routingModel.removeNode(index);
-		routingDialog.removeNode(index);
-        routingModel.insertNode(index, node);
-		routingDialog.insertNode(index,node.id+" ["+node.coor.toDisplayString()+"]");
-        Main.map.repaint();
     }
 }
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/RemoveRouteNodeAction.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/RemoveRouteNodeAction.java	(revision 14403)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/RemoveRouteNodeAction.java	(revision 14404)
@@ -67,12 +67,4 @@
 	 */
 	static Logger logger = Logger.getLogger(RoutingLayer.class);
-    /**
-     * Routing Model.
-     */
-	private RoutingModel routingModel;
-	/**
-	 * Routing Layer.
-	 */
-    private RoutingLayer routingLayer;
 	/**
 	 * Routing Dialog.
@@ -85,6 +77,4 @@
 				tr("Remove route nodes"),
 				mapFrame, ImageProvider.getCursor("normal", "delete"));
-        this.routingLayer = RoutingPlugin.getInstance().getRoutingLayer();
-        this.routingModel = routingLayer.getRoutingModel();
         this.routingDialog = RoutingPlugin.getInstance().getRoutingDialog();
 	}
@@ -103,26 +93,30 @@
         // If left button is clicked
         if (e.getButton() == MouseEvent.BUTTON1) {
-        	// Search for the nearest node in the list
-        	List<Node> nl = routingModel.getSelectedNodes();
-        	int index = -1;
-        	double dmax = REMOVE_SQR_RADIUS; // maximum distance, in pixels
-           	for (int i=0;i<nl.size();i++) {
-           		Node node = nl.get(i);
-        		double d = Main.map.mapView.getPoint(node.eastNorth).distanceSq(e.getPoint());
-        		if (d < dmax) {
-        			dmax = d;
-        			index = i;
-        		}
+        	if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
+        		RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+        		RoutingModel routingModel = layer.getRoutingModel();
+            	// Search for the nearest node in the list
+            	List<Node> nl = routingModel.getSelectedNodes();
+            	int index = -1;
+            	double dmax = REMOVE_SQR_RADIUS; // maximum distance, in pixels
+               	for (int i=0;i<nl.size();i++) {
+               		Node node = nl.get(i);
+            		double d = Main.map.mapView.getPoint(node.eastNorth).distanceSq(e.getPoint());
+            		if (d < dmax) {
+            			dmax = d;
+            			index = i;
+            		}
+            	}
+               	// If found a close node, remove it and recalculate route
+                if (index >= 0) {
+                	// Remove node
+                	logger.debug("Removing node " + nl.get(index));
+                    routingModel.removeNode(index);
+            		routingDialog.removeNode(index);
+                    Main.map.repaint();
+                } else {
+                	logger.debug("Can't find a node to remove.");
+                }
         	}
-           	// If found a close node, remove it and recalculate route
-            if (index >= 0) {
-            	// Remove node
-            	logger.debug("Removing node " + nl.get(index));
-                routingModel.removeNode(index);
-        		routingDialog.removeNode(index);
-                Main.map.repaint();
-            } else {
-            	logger.debug("Can't find a node to remove.");
-            }
         }
     }
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java	(revision 14403)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java	(revision 14404)
@@ -41,6 +41,11 @@
 import javax.swing.border.EtchedBorder;
 
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
 import org.openstreetmap.josm.tools.Shortcut;
+
+import com.innovant.josm.plugin.routing.RoutingLayer;
+import com.innovant.josm.plugin.routing.RoutingModel;
 
 
@@ -119,6 +124,6 @@
 	 * @param obj
 	 */
-	public void addNode(Object txt) {
-		model.addElement(txt);
+	public void addNode(Node n) {
+		model.addElement(n.id+" ["+n.coor.toDisplayString()+"]");
 	}
 
@@ -128,6 +133,6 @@
 	 * @param obj
 	 */
-	public void insertNode(int index, Object txt) {
-		model.insertElementAt(txt, index);
+	public void insertNode(int index, Node n) {
+		model.insertElementAt(n.id+" ["+n.coor.toDisplayString()+"]", index);
 	}
 
@@ -139,3 +144,13 @@
 	}
 
+	public void refresh() {
+		clearNodes();
+    	if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
+    		RoutingLayer routingLayer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+    		RoutingModel routingModel = routingLayer.getRoutingModel();
+    		for (Node n : routingModel.getSelectedNodes()) {
+    			addNode(n);
+    		}
+    	}
+	}
 }
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java	(revision 14403)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java	(revision 14404)
@@ -70,17 +70,12 @@
 	public RoutingMenu(final String name) {
 		super(name);
-		final RoutingLayer routingLayer = RoutingPlugin.getInstance().getRoutingLayer();
-		final RoutingModel routingModel = routingLayer.getRoutingModel();
 
 		JMenuItem mi;
 		JMenu m;
 
-		startMI = new JMenuItem(tr("Start routing"));
+		startMI = new JMenuItem(tr("Add routing layer"));
 		startMI.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent e) {
-				if(!routingLayer.isLayerAdded()) {
-					routingLayer.setLayerAdded();
-					Main.main.addLayer(routingLayer);
-				}
+				RoutingPlugin.getInstance().addLayer();
 			}
 		});
@@ -96,15 +91,19 @@
 		rshorter.addItemListener(new ItemListener() {
 			public void itemStateChanged(ItemEvent e) {
-				if (e.getStateChange()==ItemEvent.SELECTED) {
-					routingModel.routingGraph.setTypeRoute(RouteType.SHORTEST);
-				} else {
-					routingModel.routingGraph.setTypeRoute(RouteType.FASTEST);
-				}
-				routingModel.routingGraph.resetGraph();
-				routingModel.routingGraph.createGraph();
-				//TODO: Change this way
-				//FIXME: do not change node but recalculate routing.
-				routingModel.setNodesChanged();
-				Main.map.repaint();
+	        	if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
+	        		RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+	        		RoutingModel routingModel = layer.getRoutingModel();
+					if (e.getStateChange()==ItemEvent.SELECTED) {
+						routingModel.routingGraph.setTypeRoute(RouteType.SHORTEST);
+					} else {
+						routingModel.routingGraph.setTypeRoute(RouteType.FASTEST);
+					}
+					routingModel.routingGraph.resetGraph();
+					routingModel.routingGraph.createGraph();
+					//TODO: Change this way
+					//FIXME: do not change node but recalculate routing.
+					routingModel.setNodesChanged();
+					Main.map.repaint();
+	        	}
 			}
 
@@ -122,10 +121,14 @@
 		cbmi.addItemListener(new ItemListener() {
 			public void itemStateChanged(ItemEvent e) {
-				if (e.getStateChange()==ItemEvent.SELECTED)
-					routingModel.routingGraph.getRoutingProfile().setOnewayUse(false);
-				else
-					routingModel.routingGraph.getRoutingProfile().setOnewayUse(true);
-				routingModel.setNodesChanged();
-				Main.map.repaint();
+	        	if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
+	        		RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+	        		RoutingModel routingModel = layer.getRoutingModel();
+					if (e.getStateChange()==ItemEvent.SELECTED)
+						routingModel.routingGraph.getRoutingProfile().setOnewayUse(false);
+					else
+						routingModel.routingGraph.getRoutingProfile().setOnewayUse(true);
+					routingModel.setNodesChanged();
+					Main.map.repaint();
+	        	}
 			}
 		});
@@ -137,6 +140,10 @@
 		reverseMI.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent e) {
-				routingModel.reverseNodes();
-				Main.map.repaint();
+	        	if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
+	        		RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+	        		RoutingModel routingModel = layer.getRoutingModel();
+					routingModel.reverseNodes();
+					Main.map.repaint();
+	        	}
 			}
 		});
@@ -146,8 +153,12 @@
 		clearMI.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent e) {
-				// Reset routing nodes and paths
-				routingModel.reset();
-				RoutingPlugin.getInstance().getRoutingDialog().clearNodes();
-				Main.map.repaint();
+	        	if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
+	        		RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+	        		RoutingModel routingModel = layer.getRoutingModel();
+					// Reset routing nodes and paths
+					routingModel.reset();
+					RoutingPlugin.getInstance().getRoutingDialog().clearNodes();
+					Main.map.repaint();
+	        	}
 			}
 		});
