Index: applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/Address.java
===================================================================
--- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/Address.java	(revision 32424)
+++ applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/Address.java	(revision 32425)
@@ -48,4 +48,5 @@
 import org.openstreetmap.josm.command.SequenceCommand;
 import org.openstreetmap.josm.data.coor.EastNorth;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -526,8 +527,9 @@
 
     private static void setNewSelection(OsmPrimitive osm) {
-        Collection<OsmPrimitive> newSelection = new LinkedList<>(Main.main.getCurrentDataSet().getSelected());
+        DataSet ds = Main.getLayerManager().getEditDataSet();
+        Collection<OsmPrimitive> newSelection = new LinkedList<>(ds.getSelected());
         newSelection.clear();
         newSelection.add(osm);
-        getCurrentDataSet().setSelected(osm);
+        ds.setSelected(osm);
     }
 }
Index: applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java
===================================================================
--- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java	(revision 32424)
+++ applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java	(revision 32425)
@@ -580,5 +580,5 @@
                     Main.info("Try to grab into a new layer when "+wmsLayer.getName()+" is already opened.");
                     // remove the duplicated layer
-                    Main.main.removeLayer(wmsLayer);
+                    Main.getLayerManager().removeLayer(wmsLayer);
                     throw new DuplicateLayerException();
                 }
Index: applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java
===================================================================
--- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java	(revision 32424)
+++ applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java	(revision 32425)
@@ -458,12 +458,12 @@
             int wmsNewLayerPos = Main.getLayerManager().getLayers().size();
             for(Layer l : Main.getLayerManager().getLayersOfType(WMSLayer.class)) {
-                int wmsPos = Main.map.mapView.getLayerPos(l);
+                int wmsPos = Main.getLayerManager().getLayers().indexOf(l);
                 if (wmsPos < wmsNewLayerPos) wmsNewLayerPos = wmsPos;
             }
-            Main.main.addLayer(wmsLayer);
+            Main.getLayerManager().addLayer(wmsLayer);
             // Move the layer to its new position
             Main.map.mapView.moveLayer(wmsLayer, wmsNewLayerPos);
         } else
-            Main.main.addLayer(wmsLayer);
+            Main.getLayerManager().addLayer(wmsLayer);
     }
 
Index: applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGBuilding.java
===================================================================
--- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGBuilding.java	(revision 32424)
+++ applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGBuilding.java	(revision 32425)
@@ -142,5 +142,5 @@
         // check if the new way or its nodes is already in OSM layer
         for (Node n : svgDataSet.getNodes()) {
-            Node nearestNewNode = checkNearestNode(n, Main.main.getCurrentDataSet().getNodes());
+            Node nearestNewNode = checkNearestNode(n, Main.getLayerManager().getEditDataSet().getNodes());
             if (nearestNewNode != n) {
                 // replace the SVG node by the OSM node
Index: applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSVectorImage.java
===================================================================
--- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSVectorImage.java	(revision 32424)
+++ applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSVectorImage.java	(revision 32425)
@@ -43,5 +43,5 @@
                         // set raster image commune bounding box based on current view (before adjustment)
                         JOptionPane.showMessageDialog(Main.parent,tr("This commune is not vectorized.\nPlease use the other menu entry to georeference a \"Plan image\""));
-                        Main.main.removeLayer(wmsLayer);
+                        Main.getLayerManager().removeLayer(wmsLayer);
                         wmsLayer = null;
                         return;
@@ -56,5 +56,5 @@
             else if(wmsLayer.getImages().size()==0)
               // failed to contact WMS of find this commune. Remove layer if empty.
-              Main.main.removeLayer(wmsLayer);
+              Main.getLayerManager().removeLayer(wmsLayer);
         } catch (DuplicateLayerException e) {
             // we tried to grab onto a duplicated layer (removed)
Index: applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/RasterImageGeoreferencer.java
===================================================================
--- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/RasterImageGeoreferencer.java	(revision 32424)
+++ applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/RasterImageGeoreferencer.java	(revision 32425)
@@ -159,5 +159,5 @@
      if (selectedValue == 0) { // "Cancel"
          // remove layer
-         Main.main.removeLayer(wmsLayer);
+         Main.getLayerManager().removeLayer(wmsLayer);
          wmsLayer = null;
          Main.map.mapView.removeMouseListener(this);
@@ -348,5 +348,5 @@
      actionCompleted();
      if (wmsLayer != null) {
-         Main.main.removeLayer(wmsLayer);
+         Main.getLayerManager().removeLayer(wmsLayer);
          wmsLayer = null;
      }
