Index: applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/ChannelDiGraphLayer.java
===================================================================
--- applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/ChannelDiGraphLayer.java	(revision 32422)
+++ applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/ChannelDiGraphLayer.java	(revision 32423)
@@ -22,6 +22,9 @@
 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
 import org.openstreetmap.josm.gui.MapView;
-import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
 import org.openstreetmap.josm.gui.layer.Layer;
+import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
+import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
+import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;
+import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;
 import org.openstreetmap.josm.plugins.JunctionChecker.datastructure.Channel;
 import org.openstreetmap.josm.plugins.JunctionChecker.datastructure.ChannelDiGraph;
@@ -34,5 +37,5 @@
  *
  */
-public class ChannelDiGraphLayer extends Layer implements LayerChangeListener, PropertyChangeListener{
+public class ChannelDiGraphLayer extends Layer implements LayerChangeListener, PropertyChangeListener {
 
     private ChannelDiGraph digraph;
@@ -61,5 +64,5 @@
     public ChannelDiGraphLayer(ColorSchemeXMLReader cXMLReader){
         super("ChannelDiGraphLayer");
-        MapView.addLayerChangeListener(this);
+        Main.getLayerManager().addLayerChangeListener(this);
         this.cXMLReader = cXMLReader;
         initColors();
@@ -180,5 +183,4 @@
     }
 
-
     @Override
     public void visitBoundingBox(BoundingXYVisitor v) {
@@ -189,14 +191,16 @@
     }
 
-    public void activeLayerChange(Layer oldLayer, Layer newLayer) {
-
-    }
-
-    public void layerAdded(Layer newLayer) {
-    }
-
-    public void layerRemoved(Layer oldLayer) {
-        if (oldLayer == this) {
-            MapView.removeLayerChangeListener(this);
+    @Override
+    public void layerOrderChanged(LayerOrderChangeEvent e) {
+    }
+
+    @Override
+    public void layerAdded(LayerAddEvent e) {
+    }
+
+    @Override
+    public void layerRemoving(LayerRemoveEvent e) {
+        if (e.getRemovedLayer() == this) {
+            Main.getLayerManager().removeLayerChangeListener(this);
         }
     }
@@ -210,4 +214,5 @@
     }
 
+    @Override
     public void propertyChange(PropertyChangeEvent evt) {
     }
Index: applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/DigraphCreationTask.java
===================================================================
--- applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/DigraphCreationTask.java	(revision 32422)
+++ applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/DigraphCreationTask.java	(revision 32423)
@@ -55,5 +55,5 @@
     protected void finish() {
         if (canceled) {
-            Main.main.removeLayer(plugin.getChannelDigraphLayer());
+            Main.getLayerManager().removeLayer(plugin.getChannelDigraphLayer());
             return;
         }
@@ -69,5 +69,5 @@
             return;
         }
-        Main.main.removeLayer(plugin.getChannelDigraphLayer());
+        Main.getLayerManager().removeLayer(plugin.getChannelDigraphLayer());
         int tickscounter = 4;
         if (sealGraph) {
@@ -85,20 +85,20 @@
         //Der vom Benutzer in JOSM ausgewählte, zur Zeit aktive Layer wird der PLugin-OSM-Layer
         plugin.setOsmlayer((OsmDataLayer)Main.getLayerManager().getActiveLayer());
-        Iterator<Node> it = Main.main.getCurrentDataSet().getNodes().iterator();
+        Iterator<Node> it = Main.getLayerManager().getEditDataSet().getNodes().iterator();
         while (it.hasNext()) {
             graph.addNode(it.next());
         }
 
-        Iterator<Way> itway = Main.main.getCurrentDataSet().getWays()
+        Iterator<Way> itway = Main.getLayerManager().getEditDataSet().getWays()
         .iterator();
         while (itway.hasNext()) {
             graph.addWay(itway.next());
         }
-        Iterator<Relation> itrel = Main.main.getCurrentDataSet().getRelations()
+        Iterator<Relation> itrel = Main.getLayerManager().getEditDataSet().getRelations()
         .iterator();
         while (itrel.hasNext()) {
             graph.addRelation(itrel.next());
         }
-        Iterator<DataSource> itdata = Main.main.getCurrentDataSet().dataSources.iterator();
+        Iterator<DataSource> itdata = Main.getLayerManager().getEditDataSet().dataSources.iterator();
         while (itdata.hasNext()) {
             Bounds b = itdata.next().bounds;
@@ -146,5 +146,5 @@
         plugin.setNormalMapMode(Main.map.mapMode);
         Main.map.selectMapMode(plugin.getJcMapMode());
-        Main.main.addLayer(plugin.getChannelDigraphLayer());
+        Main.getLayerManager().addLayer(plugin.getChannelDigraphLayer());
         Main.getLayerManager().setActiveLayer(plugin.getChannelDigraphLayer());
     }
Index: applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/JunctionCheckerMapMode.java
===================================================================
--- applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/JunctionCheckerMapMode.java	(revision 32422)
+++ applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/JunctionCheckerMapMode.java	(revision 32423)
@@ -9,11 +9,12 @@
 import java.awt.event.InputEvent;
 import java.awt.event.MouseEvent;
+
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.mapmode.MapMode;
 import org.openstreetmap.josm.data.coor.LatLon;
 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.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
+import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
 import org.openstreetmap.josm.plugins.JunctionChecker.datastructure.ChannelDiGraph;
 
@@ -22,5 +23,5 @@
  * die eigenen Bedürfnisse angepaßt
  */
-public class JunctionCheckerMapMode extends MapMode implements LayerChangeListener{
+public class JunctionCheckerMapMode extends MapMode implements ActiveLayerChangeListener {
 
     MapFrame frame;
@@ -40,5 +41,5 @@
         Main.map.mapView.addMouseListener(this);
         Main.map.mapView.addMouseMotionListener(this);
-        MapView.addLayerChangeListener(this);
+        Main.getLayerManager().addActiveLayerChangeListener(this);
     }
 
@@ -49,17 +50,11 @@
     }
 
-
-    public void activeLayerChange(Layer oldLayer, Layer newLayer) {
+    @Override
+    public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
+        Layer newLayer = Main.getLayerManager().getActiveLayer();
         if (newLayer instanceof ChannelDiGraphLayer) {
             layer = (ChannelDiGraphLayer) newLayer;
         }
     }
-
-    public void layerAdded(Layer newLayer) {
-    }
-
-    public void layerRemoved(Layer oldLayer) {
-    }
-
 
     public void setFrame(MapFrame newFrame) {
@@ -169,5 +164,5 @@
     public void destroy() {
         super.destroy();
-        MapView.removeLayerChangeListener(this);
+        Main.getLayerManager().removeActiveLayerChangeListener(this);
     }
 }
Index: applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/JunctionCheckerPlugin.java
===================================================================
--- applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/JunctionCheckerPlugin.java	(revision 32422)
+++ applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/JunctionCheckerPlugin.java	(revision 32423)
@@ -7,10 +7,13 @@
 
 import java.io.File;
+
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.mapmode.MapMode;
 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.gui.layer.LayerManager.LayerAddEvent;
+import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
+import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;
+import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 import org.openstreetmap.josm.plugins.Plugin;
@@ -26,5 +29,5 @@
  * 
  */
-public class JunctionCheckerPlugin extends Plugin implements LayerChangeListener{
+public class JunctionCheckerPlugin extends Plugin implements LayerChangeListener {
 
     private static final String COLORSCHEMEFILTERFILE = "/resources/xml/colorscheme.xml";
@@ -53,7 +56,7 @@
             junctionCheckDialog = new JunctionCheckDialog(this);
             newFrame.addToggleDialog(junctionCheckDialog);
-            MapView.addLayerChangeListener(this);
+            Main.getLayerManager().addLayerChangeListener(this);
         } else
-            MapView.removeLayerChangeListener(this);
+            Main.getLayerManager().removeLayerChangeListener(this);
     }
 
@@ -72,9 +75,15 @@
     }
 
-    public void layerAdded(Layer newLayer) {
+    @Override
+    public void layerOrderChanged(LayerOrderChangeEvent e) {
     }
 
-    public void layerRemoved(Layer oldLayer) {
-        if (oldLayer == channelDigraphLayer) {
+    @Override
+    public void layerAdded(LayerAddEvent e) {
+    }
+
+    @Override
+    public void layerRemoving(LayerRemoveEvent e) {
+        if (e.getRemovedLayer() == channelDigraphLayer) {
             channelDigraphLayer = null;
             this.getJunctionCheckDialog().setActivateJunctionCheckOrSearch(false);
Index: applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/junctionchecking/JMinimality.java
===================================================================
--- applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/junctionchecking/JMinimality.java	(revision 32422)
+++ applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/junctionchecking/JMinimality.java	(revision 32423)
@@ -13,6 +13,4 @@
 import org.openstreetmap.josm.plugins.JunctionChecker.datastructure.Channel;
 import org.openstreetmap.josm.plugins.JunctionChecker.datastructure.ChannelDiGraph;
-
-
 
 /**
@@ -29,5 +27,4 @@
     private final int n;
     private final List<List<Object>> L = new ArrayList<>(); //The list of columns to be sorted
-    private long EEovern = 0;
     private final HashSet<Channel> subgraph = new HashSet<>();//The candidate subgraph to be tested
     private ProgressMonitor pm;
@@ -39,5 +36,4 @@
     private boolean Check = false;
     private Iterator<int[]> it;
-
 
     public JMinimality(int[][] Grid, int n,
@@ -84,5 +80,5 @@
 
         Combination c = new Combination(Grid.length, n);
-        EEovern = (int) Combination.Choose(Grid.length*Grid.length, n*n);
+        //EEovern = (int) Combination.Choose(Grid.length*Grid.length, n*n);
         long ans = c.Choose(); //This is the number of subcolumns to be generated
         int[][] v; // this is a column variable containing n y-index entries plus true false values (0/1)
Index: applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/junctionchecking/JPrepare.java
===================================================================
--- applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/junctionchecking/JPrepare.java	(revision 32422)
+++ applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/junctionchecking/JPrepare.java	(revision 32423)
@@ -2,4 +2,5 @@
 
 import java.util.ArrayList;
+
 import org.openstreetmap.josm.plugins.JunctionChecker.datastructure.Channel;
 import org.openstreetmap.josm.plugins.JunctionChecker.datastructure.ChannelDiGraph;
@@ -14,10 +15,8 @@
     private final ArrayList<Channel> exits;
     private ArrayList<Channel> vertices;
-    private final ChannelDiGraph digraph;
 
     public JPrepare(ChannelDiGraph digraph) {
         entries = new ArrayList<>();
         exits = new ArrayList<>();
-        this.digraph = digraph;
     }
 
Index: applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/junctionchecking/TRDFS.java
===================================================================
--- applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/junctionchecking/TRDFS.java	(revision 32422)
+++ applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/junctionchecking/TRDFS.java	(revision 32423)
@@ -2,9 +2,9 @@
 
 import java.util.ArrayList;
+
 import org.openstreetmap.josm.plugins.JunctionChecker.connectedness.BacktrackingColors;
 import org.openstreetmap.josm.plugins.JunctionChecker.datastructure.Channel;
 import org.openstreetmap.josm.plugins.JunctionChecker.datastructure.ChannelDiGraph;
 import org.openstreetmap.josm.plugins.JunctionChecker.datastructure.LeadsTo;
-
 
 /**
@@ -13,6 +13,4 @@
 public class TRDFS {
 
-    private final ArrayList<Channel> vertices;
-    private Channel startNode;
     private final ArrayList<LeadsTo> cycleEdges;
     private final ChannelDiGraph digraph;
@@ -24,9 +22,7 @@
      */
     public TRDFS(ArrayList<Channel> adnodes, ChannelDiGraph digraph) {
-        this.vertices = adnodes;
         this.digraph = digraph;
         this.cycleEdges = new ArrayList<>();
     }
-
 
     public void trdfs(Channel startNode) {
