diff --git a/CommandLine/src/CommandLine/CommandLine.java b/CommandLine/src/CommandLine/CommandLine.java
index 3bc73ff..5a760ef 100644
--- a/CommandLine/src/CommandLine/CommandLine.java
+++ b/CommandLine/src/CommandLine/CommandLine.java
@@ -368,10 +368,10 @@ public class CommandLine extends Plugin {
                 action = new DummyAction(currentMapFrame, this);
                 break;
             case IMAGERYURL:
-                Layer layer = Main.map.mapView.getActiveLayer();
+                Layer layer = Main.getLayerManager().getActiveLayer();
                 if (layer != null) {
                     if (!(layer instanceof ImageryLayer)) {
-                        List<ImageryLayer> imageryLayers = Main.map.mapView.getLayersOfType(ImageryLayer.class);
+                        List<ImageryLayer> imageryLayers = Main.getLayerManager().getLayersOfType(ImageryLayer.class);
                         if (imageryLayers.size() == 1) {
                             layer = imageryLayers.get(0);
                         }
@@ -388,10 +388,10 @@ public class CommandLine extends Plugin {
                 action = new DummyAction(currentMapFrame, this);
                 break;
             case IMAGERYOFFSET:
-                Layer olayer = Main.map.mapView.getActiveLayer();
+                Layer olayer = Main.getLayerManager().getActiveLayer();
                 if (olayer != null) {
                     if (!(olayer instanceof ImageryLayer)) {
-                        List<ImageryLayer> imageryLayers = Main.map.mapView.getLayersOfType(ImageryLayer.class);
+                        List<ImageryLayer> imageryLayers = Main.getLayerManager().getLayersOfType(ImageryLayer.class);
                         if (imageryLayers.size() == 1) {
                             olayer = imageryLayers.get(0);
                         }
@@ -596,7 +596,7 @@ public class CommandLine extends Plugin {
                     try (GpxWriter gpxWriter = new GpxWriter(printWriter)) {
                         GpxFilter gpxFilter = new GpxFilter();
                         gpxFilter.initBboxFilter(bbox);
-                        List<GpxLayer> gpxLayers = Main.map.mapView.getLayersOfType(GpxLayer.class);
+                        List<GpxLayer> gpxLayers = Main.getLayerManager().getLayersOfType(GpxLayer.class);
                         for (GpxLayer gpxLayer : gpxLayers) {
                             gpxFilter.addGpxData(gpxLayer.data);
                         }
diff --git a/DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload/UploadOsmConnection.java b/DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload/UploadOsmConnection.java
index e396af8..1e78cf1 100644
--- a/DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload/UploadOsmConnection.java
+++ b/DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload/UploadOsmConnection.java
@@ -10,6 +10,7 @@ import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
 import org.openstreetmap.josm.gui.layer.GpxLayer;
 import org.openstreetmap.josm.gui.layer.Layer;
+import org.openstreetmap.josm.gui.layer.MainLayerManager;
 import org.openstreetmap.josm.io.OsmConnection;
 import org.openstreetmap.josm.io.OsmTransferException;
 import org.openstreetmap.josm.tools.HttpClient;
@@ -48,10 +49,10 @@ public class UploadOsmConnection extends OsmConnection {
      */
     GpxData autoSelectTrace() {
         if (Main.map != null && Main.map.mapView != null) {
-            MapView mv = Main.map.mapView;
+            MainLayerManager lm = Main.getLayerManager();
 //            List<Layer> allLayers = new ArrayList<Layer>(mv.getAllLayersAsList());  // modifiable
             List<Layer> selectedLayers = LayerListDialog.getInstance().getModel().getSelectedLayers();
-            List<GpxLayer> gpxLayersRemaining = mv.getLayersOfType(GpxLayer.class);
+            List<GpxLayer> gpxLayersRemaining = lm.getLayersOfType(GpxLayer.class);
             gpxLayersRemaining.removeAll(selectedLayers);
             GpxLayer traceLayer = null;
             // find the first gpx layer inside selected layers
@@ -67,14 +68,13 @@ public class UploadOsmConnection extends OsmConnection {
                     traceLayer = gpxLayersRemaining.get(0);
                 }
                 // active layer
-                else if (mv.getActiveLayer() instanceof GpxLayer) {
-                    traceLayer = (GpxLayer) mv.getActiveLayer();
+                else if (lm.getActiveLayer() instanceof GpxLayer) {
+                    traceLayer = (GpxLayer) lm.getActiveLayer();
                 }
             }
 
             if (traceLayer != null) {
-                GpxData data = traceLayer.data;
-                return data;
+                return traceLayer.data;
             }
         }
 
diff --git a/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java b/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java
index 8398071..00e12ab 100644
--- a/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java
+++ b/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java
@@ -195,7 +195,7 @@ public class ElevationProfileDialog extends ToggleDialog implements LayerChangeL
 	public void showNotify() {
 		MapView.addLayerChangeListener(this);
 		if (Main.isDisplayingMapView()) {
-			Layer layer = Main.map.mapView.getActiveLayer();
+			Layer layer = Main.getLayerManager().getActiveLayer();
 			if (layer instanceof GpxLayer) {
 				setActiveLayer((GpxLayer) layer);
 			}
diff --git a/NanoLog/src/nanolog/GPXChooser.java b/NanoLog/src/nanolog/GPXChooser.java
index cded6dd..a9dc1c7 100644
--- a/NanoLog/src/nanolog/GPXChooser.java
+++ b/NanoLog/src/nanolog/GPXChooser.java
@@ -18,7 +18,7 @@ public class GPXChooser extends JDialog {
 
     public static GpxLayer topLayer() {
         // return first found local layer
-        for( Layer layer : Main.map.mapView.getAllLayers() ) {
+        for( Layer layer : Main.getLayerManager().getLayers() ) {
             if( layer instanceof GpxLayer && ((GpxLayer)layer).isLocalFile() )
                 return (GpxLayer)layer;
         }
diff --git a/NanoLog/src/nanolog/NanoLogLayer.java b/NanoLog/src/nanolog/NanoLogLayer.java
index 36616d1..3592de7 100644
--- a/NanoLog/src/nanolog/NanoLogLayer.java
+++ b/NanoLog/src/nanolog/NanoLogLayer.java
@@ -297,7 +297,7 @@ public class NanoLogLayer extends Layer implements JumpToMarkerActions.JumpToMar
         @Override
         public void mousePressed( MouseEvent e ) {
             int nearest = nearestEntry(e);
-            if( nearest > 0 && Main.map.mapView.getActiveLayer() == NanoLogLayer.this ) {
+            if( nearest > 0 && Main.getLayerManager().getActiveLayer() == NanoLogLayer.this ) {
                 dragging = nearest;
                 doDrag(e);
             }
diff --git a/NanoLog/src/nanolog/NanoLogPanel.java b/NanoLog/src/nanolog/NanoLogPanel.java
index 25247b1..a4e1e71 100644
--- a/NanoLog/src/nanolog/NanoLogPanel.java
+++ b/NanoLog/src/nanolog/NanoLogPanel.java
@@ -36,7 +36,7 @@ public class NanoLogPanel extends ToggleDialog implements LayerChangeListener, N
 
     public void updateMarkers() {
         List<NanoLogEntry> entries = new ArrayList<>();
-        for( NanoLogLayer l : Main.map.mapView.getLayersOfType(NanoLogLayer.class) ) {
+        for( NanoLogLayer l : Main.getLayerManager().getLayersOfType(NanoLogLayer.class) ) {
             entries.addAll(l.getEntries());
         }
         listModel.setEntries(entries);
diff --git a/cadastre-fr/src/cadastre_fr/CadastreInterface.java b/cadastre-fr/src/cadastre_fr/CadastreInterface.java
index c48b7c9..f41b6e3 100644
--- a/cadastre-fr/src/cadastre_fr/CadastreInterface.java
+++ b/cadastre-fr/src/cadastre_fr/CadastreInterface.java
@@ -575,7 +575,7 @@ public class CadastreInterface {
 
     private static void checkLayerDuplicates(WMSLayer wmsLayer) throws DuplicateLayerException {
         if (Main.map != null) {
-            for (Layer l : Main.map.mapView.getAllLayers()) {
+            for (Layer l : Main.getLayerManager().getLayers()) {
                 if (l instanceof WMSLayer && l.getName().equals(wmsLayer.getName()) && (!l.equals(wmsLayer))) {
                     Main.info("Try to grab into a new layer when "+wmsLayer.getName()+" is already opened.");
                     // remove the duplicated layer
diff --git a/cadastre-fr/src/cadastre_fr/CadastrePlugin.java b/cadastre-fr/src/cadastre_fr/CadastrePlugin.java
index c04dcec..cfb36bb 100644
--- a/cadastre-fr/src/cadastre_fr/CadastrePlugin.java
+++ b/cadastre-fr/src/cadastre_fr/CadastrePlugin.java
@@ -455,8 +455,8 @@ public class CadastrePlugin extends Plugin {
      */
     public static void addWMSLayer(WMSLayer wmsLayer) {
         if (Main.map != null && Main.map.mapView != null) {
-            int wmsNewLayerPos = Main.map.mapView.getAllLayers().size();
-            for(Layer l : Main.map.mapView.getLayersOfType(WMSLayer.class)) {
+            int wmsNewLayerPos = Main.getLayerManager().getLayers().size();
+            for(Layer l : Main.getLayerManager().getLayersOfType(WMSLayer.class)) {
                 int wmsPos = Main.map.mapView.getLayerPos(l);
                 if (wmsPos < wmsNewLayerPos) wmsNewLayerPos = wmsPos;
             }
diff --git a/cadastre-fr/src/cadastre_fr/MenuActionGrabPlanImage.java b/cadastre-fr/src/cadastre_fr/MenuActionGrabPlanImage.java
index 7bea280..62453af 100644
--- a/cadastre-fr/src/cadastre_fr/MenuActionGrabPlanImage.java
+++ b/cadastre-fr/src/cadastre_fr/MenuActionGrabPlanImage.java
@@ -1,8 +1,8 @@
 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others
 package cadastre_fr;
 
-import static org.openstreetmap.josm.tools.I18n.tr;
 import static org.openstreetmap.josm.tools.I18n.marktr;
+import static org.openstreetmap.josm.tools.I18n.tr;
 
 import java.awt.event.ActionEvent;
 import java.util.ArrayList;
@@ -11,7 +11,6 @@ import javax.swing.JOptionPane;
 
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.JosmAction;
-import org.openstreetmap.josm.gui.layer.Layer;
 
 public class MenuActionGrabPlanImage extends JosmAction implements Runnable {
 
@@ -35,14 +34,14 @@ public class MenuActionGrabPlanImage extends JosmAction implements Runnable {
     protected void updateEnabledState() {
         if (wmsLayer == null || Main.map == null || Main.map.mapView == null) return;
         if (!rasterImageGeoreferencer.isRunning()) return;
-        for (Layer l : Main.map.mapView.getAllLayersAsList())
-            if (l == wmsLayer)
-                return;
+        if (Main.getLayerManager().containsLayer(wmsLayer))
+        	return;
         JOptionPane.showMessageDialog(Main.parent, tr("Georeferencing interrupted"));
         rasterImageGeoreferencer.actionInterrupted();
     }
 
-    public void actionPerformed(ActionEvent ae) {
+    @Override
+	public void actionPerformed(ActionEvent ae) {
         if (Main.map != null) {
             if (CadastrePlugin.isCadastreProjection()) {
                 wmsLayer = new MenuActionNewLocation().addNewLayer(new ArrayList<WMSLayer>());
@@ -57,7 +56,8 @@ public class MenuActionGrabPlanImage extends JosmAction implements Runnable {
         }
     }
 
-    public void run() {
+    @Override
+	public void run() {
         // wait until plan image is fully loaded and joined into one single image
         boolean loadedFromCache = downloadWMSPlanImage.waitFinished();
         if (loadedFromCache) {
diff --git a/cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java b/cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java
index 7c4f214..f29fb34 100644
--- a/cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java
+++ b/cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java
@@ -68,7 +68,7 @@ public class MenuActionLoadFromCache extends JosmAction {
                     }
                     // check if the selected cache is not already displayed
                     if (Main.map != null) {
-                        for (Layer l : Main.map.mapView.getAllLayers()) {
+                        for (Layer l : Main.getLayerManager().getLayers()) {
                             if (l instanceof WMSLayer && l.getName().equals(location)) {
                                 JOptionPane.showMessageDialog(Main.parent, tr("The location {0} is already on screen. Cache not loaded.", filename), tr("Error"), JOptionPane.ERROR_MESSAGE);
                                 continue nextFile;
diff --git a/cadastre-fr/src/cadastre_fr/MenuActionNewLocation.java b/cadastre-fr/src/cadastre_fr/MenuActionNewLocation.java
index 963e2f7..aa09278 100644
--- a/cadastre-fr/src/cadastre_fr/MenuActionNewLocation.java
+++ b/cadastre-fr/src/cadastre_fr/MenuActionNewLocation.java
@@ -105,7 +105,7 @@ public class MenuActionNewLocation extends JosmAction {
             Main.pref.put("cadastrewms.codeCommune", codeCommune);
             Main.pref.put("cadastrewms.codeDepartement", codeDepartement);
             if (Main.map != null) {
-                for (Layer l : Main.map.mapView.getAllLayers()) {
+                for (Layer l : Main.getLayerManager().getLayers()) {
                     if (l instanceof WMSLayer && l.getName().equalsIgnoreCase(location)) {
                         return null;
                     }
@@ -117,8 +117,8 @@ public class MenuActionNewLocation extends JosmAction {
             wmsLayer.setDepartement(codeDepartement);
             CadastrePlugin.addWMSLayer(wmsLayer);
             Main.info("Add new layer with Location:" + inputTown.getText());
-        } else if (existingLayers != null && existingLayers.size() > 0 && Main.map.mapView.getActiveLayer() instanceof WMSLayer) {
-            wmsLayer = (WMSLayer)Main.map.mapView.getActiveLayer();
+        } else if (existingLayers != null && existingLayers.size() > 0 && Main.getLayerManager().getActiveLayer() instanceof WMSLayer) {
+            wmsLayer = (WMSLayer)Main.getLayerManager().getActiveLayer();
         }
 
         return wmsLayer;
diff --git a/cadastre-fr/src/cadastre_fr/WMSAdjustAction.java b/cadastre-fr/src/cadastre_fr/WMSAdjustAction.java
index d400742..e2f817e 100644
--- a/cadastre-fr/src/cadastre_fr/WMSAdjustAction.java
+++ b/cadastre-fr/src/cadastre_fr/WMSAdjustAction.java
@@ -40,8 +40,8 @@ public class WMSAdjustAction extends MapMode implements
 
     @Override public void enterMode() {
         if (Main.map != null) {
-            if (Main.map.mapView.getActiveLayer() instanceof WMSLayer) {
-                modifiedLayer = (WMSLayer)Main.map.mapView.getActiveLayer();
+            if (Main.getLayerManager().getActiveLayer() instanceof WMSLayer) {
+                modifiedLayer = (WMSLayer)Main.getLayerManager().getActiveLayer();
                 super.enterMode();
                 Main.map.mapView.addMouseListener(this);
                 Main.map.mapView.addMouseMotionListener(this);
diff --git a/cadastre-fr/src/cadastre_fr/WMSDownloadAction.java b/cadastre-fr/src/cadastre_fr/WMSDownloadAction.java
index c427c04..6700e9d 100644
--- a/cadastre-fr/src/cadastre_fr/WMSDownloadAction.java
+++ b/cadastre-fr/src/cadastre_fr/WMSDownloadAction.java
@@ -26,10 +26,10 @@ public class WMSDownloadAction /*extends JosmAction */{
         // check if we already have a layer created. if not, create; if yes, reuse.
         ArrayList<WMSLayer> existingWMSlayers = new ArrayList<>();
         if (Main.map != null) {
-            Layer activeLayer = Main.map.mapView.getActiveLayer();
+            Layer activeLayer = Main.getLayerManager().getActiveLayer();
             if (activeLayer instanceof WMSLayer)
                 return (WMSLayer) activeLayer;
-            for (Layer l : Main.map.mapView.getAllLayers()) {
+            for (Layer l : Main.getLayerManager().getLayers()) {
                 if (l instanceof WMSLayer) {
                     existingWMSlayers.add((WMSLayer)l);
                 }
diff --git a/cadastre-fr/src/cadastre_fr/WMSLayer.java b/cadastre-fr/src/cadastre_fr/WMSLayer.java
index 42a9be5..045a001 100644
--- a/cadastre-fr/src/cadastre_fr/WMSLayer.java
+++ b/cadastre-fr/src/cadastre_fr/WMSLayer.java
@@ -159,7 +159,7 @@ public class WMSLayer extends Layer implements ImageObserver {
         grabThread.setCanceled(false);
         grabThread.setGrabber(grabber);
         // if it is the first layer, use the communeBBox as grab bbox (and not divided)
-        if (Main.map.mapView.getAllLayers().size() == 1 ) {
+        if (Main.getLayerManager().getLayers().size() == 1 ) {
             final Bounds bounds = this.getCommuneBBox().toBounds();
             GuiHelper.runInEDTAndWait(new Runnable() {
                 @Override
diff --git a/editgpx/src/org/openstreetmap/josm/plugins/editgpx/EditGpxMode.java b/editgpx/src/org/openstreetmap/josm/plugins/editgpx/EditGpxMode.java
index b19bf33..47ae8ac 100644
--- a/editgpx/src/org/openstreetmap/josm/plugins/editgpx/EditGpxMode.java
+++ b/editgpx/src/org/openstreetmap/josm/plugins/editgpx/EditGpxMode.java
@@ -159,7 +159,7 @@ public class EditGpxMode extends MapMode implements LayerChangeListener {
      */
     private void updateLayer() {
 
-        List<EditGpxLayer> layers = Main.map.mapView.getLayersOfType(EditGpxLayer.class);
+        List<EditGpxLayer> layers = Main.getLayerManager().getLayersOfType(EditGpxLayer.class);
         currentEditLayer = layers.isEmpty()?null:layers.get(0);
 
         if(currentEditLayer == null) {
@@ -178,7 +178,7 @@ public class EditGpxMode extends MapMode implements LayerChangeListener {
         if (oldLayer instanceof EditGpxLayer) {
             currentEditLayer = null;
             if (Main.map.mapMode instanceof EditGpxMode) {
-                if (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer) {
+                if (Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer) {
                     Main.map.selectSelectTool(false);
                 } else {
                     Main.map.selectZoomTool(false);
diff --git a/editgpx/src/org/openstreetmap/josm/plugins/editgpx/GPXLayerImportAction.java b/editgpx/src/org/openstreetmap/josm/plugins/editgpx/GPXLayerImportAction.java
index dced68c..e14d438 100644
--- a/editgpx/src/org/openstreetmap/josm/plugins/editgpx/GPXLayerImportAction.java
+++ b/editgpx/src/org/openstreetmap/josm/plugins/editgpx/GPXLayerImportAction.java
@@ -52,7 +52,7 @@ class GPXLayerImportAction extends AbstractAction {
         DefaultListModel<GpxLayer> dModel = new DefaultListModel<>();
 
         final JList<GpxLayer> layerList = new JList<>(dModel);
-        Collection<Layer> data = Main.map.mapView.getAllLayers();
+        Collection<Layer> data = Main.getLayerManager().getLayers();
         int layerCnt = 0;
 
         for (Layer l : data){
diff --git a/gpsblam/src/org/openstreetmap/josm/plugins/gpsblam/GPSBlamInputData.java b/gpsblam/src/org/openstreetmap/josm/plugins/gpsblam/GPSBlamInputData.java
index c1d0748..f0ca6e3 100644
--- a/gpsblam/src/org/openstreetmap/josm/plugins/gpsblam/GPSBlamInputData.java
+++ b/gpsblam/src/org/openstreetmap/josm/plugins/gpsblam/GPSBlamInputData.java
@@ -26,7 +26,7 @@ class GPSBlamInputData extends LinkedList<CachedLatLon> {
     // select a set of GPX points and count how many tracks they have come from,
     // within given radius of line between given points
     GPSBlamInputData(Point p1, Point p2, int radius) {
-        Collection<Layer> layers = Main.map.mapView.getAllLayers();
+        Collection<Layer> layers = Main.getLayerManager().getLayers();
         for (Layer l : layers) {
             if (l.isVisible() && l instanceof GpxLayer) {
                 for (GpxTrack track : ((GpxLayer)l).data.tracks) {
diff --git a/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/actions/downloadtask/DownloadXmlBoundsTask.java b/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/actions/downloadtask/DownloadXmlBoundsTask.java
index 022af80..1acbcf5 100644
--- a/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/actions/downloadtask/DownloadXmlBoundsTask.java
+++ b/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/actions/downloadtask/DownloadXmlBoundsTask.java
@@ -72,7 +72,7 @@ public class DownloadXmlBoundsTask extends DownloadOsmTask implements XmlBoundsC
         protected int getNumDataLayers() {
             int count = 0;
             if (!Main.isDisplayingMapView()) return 0;
-            for (Layer layer : Main.map.mapView.getAllLayers()) {
+            for (Layer layer : Main.getLayerManager().getLayers()) {
                 if (layer instanceof XmlBoundsLayer) {
                     count++;
                 }
@@ -83,7 +83,7 @@ public class DownloadXmlBoundsTask extends DownloadOsmTask implements XmlBoundsC
         @Override
         protected OsmDataLayer getFirstDataLayer() {
             if (!Main.isDisplayingMapView()) return null;
-            for (Layer layer : Main.map.mapView.getAllLayersAsList()) {
+            for (Layer layer : Main.getLayerManager().getLayers()) {
                 if (layer instanceof XmlBoundsLayer)
                     return (XmlBoundsLayer) layer;
             }
diff --git a/imagery_offset_db/src/iodb/ImageryOffsetTools.java b/imagery_offset_db/src/iodb/ImageryOffsetTools.java
index 28d3aeb..46a159c 100644
--- a/imagery_offset_db/src/iodb/ImageryOffsetTools.java
+++ b/imagery_offset_db/src/iodb/ImageryOffsetTools.java
@@ -29,7 +29,7 @@ public class ImageryOffsetTools {
     public static ImageryLayer getTopImageryLayer() {
         if( Main.map == null || Main.map.mapView == null )
             return null;
-        List<ImageryLayer> layers = Main.map.mapView.getLayersOfType(ImageryLayer.class);
+        List<ImageryLayer> layers = Main.getLayerManager().getLayersOfType(ImageryLayer.class);
         for( ImageryLayer layer : layers ) {
             String url = layer.getInfo().getUrl();
             if( layer.isVisible() && url != null && !url.contains("gps-") ) {
diff --git a/imageryadjust/src/imageryadjust/ImageryAdjustMapMode.java b/imageryadjust/src/imageryadjust/ImageryAdjustMapMode.java
index a1defb6..aed80b3 100644
--- a/imageryadjust/src/imageryadjust/ImageryAdjustMapMode.java
+++ b/imageryadjust/src/imageryadjust/ImageryAdjustMapMode.java
@@ -53,7 +53,7 @@ public class ImageryAdjustMapMode extends MapMode implements MouseListener, Mous
     }
     
     private List<? extends Layer> getVisibleLayers() {
-        List<? extends Layer> all = new ArrayList<Layer>(Main.map.mapView.getLayersOfType(ImageryLayer.class));
+        List<? extends Layer> all = new ArrayList<Layer>(Main.getLayerManager().getLayersOfType(ImageryLayer.class));
         Iterator<? extends Layer> it = all.iterator();
         while (it.hasNext()) {
             if (!it.next().isVisible()) it.remove();
@@ -75,7 +75,7 @@ public class ImageryAdjustMapMode extends MapMode implements MouseListener, Mous
             warnNoImageryLayers();
             return;
         }
-        List<ImageryLayer> layers = Main.map.mapView.getLayersOfType(ImageryLayer.class);
+        List<ImageryLayer> layers = Main.getLayerManager().getLayersOfType(ImageryLayer.class);
         if (layers.size() == 1) {
             adjustingLayer = layers.get(0);
         } else {
@@ -158,7 +158,7 @@ public class ImageryAdjustMapMode extends MapMode implements MouseListener, Mous
                 return false;
             if (Main.map.mapView == null)
                 return false;
-            return Main.map.mapView.getActiveLayer() == layer;
+            return Main.getLayerManager().getActiveLayer() == layer;
         }
 
         @Override
@@ -229,7 +229,7 @@ public class ImageryAdjustMapMode extends MapMode implements MouseListener, Mous
     protected boolean hasImageryLayersToAdjust() {
         if (Main.map == null) return false;
         if (Main.map.mapView == null) return false;
-        boolean b = ! Main.map.mapView.getLayersOfType(ImageryLayer.class).isEmpty();
+        boolean b = ! Main.getLayerManager().getLayersOfType(ImageryLayer.class).isEmpty();
         return b;
     }
 
diff --git a/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageEntries.java b/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageEntries.java
index 8845717..63af2b0 100644
--- a/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageEntries.java
+++ b/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageEntries.java
@@ -75,7 +75,7 @@ public final class ImageEntries {
         this.locatedImages.clear();
 
         if (null != Main.map && null != Main.map.mapView) {
-            final Collection<Layer> layerCollection = Main.map.mapView.getAllLayers();
+            final Collection<Layer> layerCollection = Main.getLayerManager().getLayers();
             final Layer[] layers = layerCollection.toArray(new Layer[layerCollection.size()]);
 
             for (int index = 0; index < layers.length; index++) {
diff --git a/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageWayPointPlugin.java b/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageWayPointPlugin.java
index 753b410..4ac1d5e 100644
--- a/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageWayPointPlugin.java
+++ b/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageWayPointPlugin.java
@@ -69,7 +69,7 @@ public final class ImageWayPointPlugin extends org.openstreetmap.josm.plugins.Pl
                 // check to see whether there's already an ImageWayPointLayer
                 boolean foundImageWayPointLayer = false;
                 if (null != Main.map && null != Main.map.mapView) {
-                    final Collection<Layer> layerCollection = Main.map.mapView.getAllLayers();
+                    final Collection<Layer> layerCollection = Main.getLayerManager().getLayers();
                     final Iterator<Layer> layerIterator = layerCollection.iterator();
                     while (layerIterator.hasNext() && !foundImageWayPointLayer) {
                         if (layerIterator.next() instanceof ImageWayPointLayer) {
diff --git a/irsrectify/src/irsrectify/IRSRectifyPlugin.java b/irsrectify/src/irsrectify/IRSRectifyPlugin.java
index 267c462..636e136 100644
--- a/irsrectify/src/irsrectify/IRSRectifyPlugin.java
+++ b/irsrectify/src/irsrectify/IRSRectifyPlugin.java
@@ -73,13 +73,13 @@ public class IRSRectifyPlugin extends Plugin {
             data.data.addPrimitive(offset);
             data.data.addPrimitive(way);
             data.data.setSelected(way.getPrimitiveId());
-            frame.mapView.setActiveLayer(data);
+            Main.getLayerManager().setActiveLayer(data);
         }
 
         private ImageryLayer findImageryLayer() {
             if( frame == null || frame.mapView == null )
                 return null;
-            for( Layer l : frame.mapView.getAllLayers() )
+            for( Layer l : Main.getLayerManager().getLayers() )
                 if( l instanceof ImageryLayer )
                     return (ImageryLayer)l;
             return null;
@@ -89,12 +89,12 @@ public class IRSRectifyPlugin extends Plugin {
             if( frame == null || frame.mapView == null )
                 return null;
 
-            OsmDataLayer l = frame.mapView.getEditLayer();
+            OsmDataLayer l = Main.getLayerManager().getEditLayer();
             if( isOffsetLayer(l) )
                 return l;
 
             // try to find among all layers
-            for( Layer layer : frame.mapView.getAllLayers() )
+            for( Layer layer : Main.getLayerManager().getLayers() )
                 if( layer instanceof OsmDataLayer && isOffsetLayer((OsmDataLayer)layer) )
                     return (OsmDataLayer) layer;
 
diff --git a/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/DigraphCreationTask.java b/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/DigraphCreationTask.java
index a58f2ad..d13d85e 100644
--- a/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/DigraphCreationTask.java
+++ b/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/DigraphCreationTask.java
@@ -64,7 +64,7 @@ public class DigraphCreationTask extends PleaseWaitRunnable {
     OsmTransferException {
         //Prüfen, ob der ausgewählte Layer ein OSMDataLayer ist
         if (Main.map == null
-                || !Main.map.isVisible() || !(Main.map.mapView.getActiveLayer() instanceof OsmDataLayer)) {
+                || !Main.map.isVisible() || !(Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer)) {
             JOptionPane.showMessageDialog(Main.parent, tr("this layer is no osm data layer"));
             return;
         }
@@ -83,7 +83,7 @@ public class DigraphCreationTask extends PleaseWaitRunnable {
 
         OSMGraph graph = new OSMGraph();
         //Der vom Benutzer in JOSM ausgewählte, zur Zeit aktive Layer wird der PLugin-OSM-Layer
-        plugin.setOsmlayer((OsmDataLayer)Main.map.mapView.getActiveLayer());
+        plugin.setOsmlayer((OsmDataLayer)Main.getLayerManager().getActiveLayer());
         Iterator<Node> it = Main.main.getCurrentDataSet().getNodes().iterator();
         while (it.hasNext()) {
             graph.addNode(it.next());
@@ -146,6 +146,6 @@ public class DigraphCreationTask extends PleaseWaitRunnable {
         plugin.setNormalMapMode(Main.map.mapMode);
         Main.map.selectMapMode(plugin.getJcMapMode());
         Main.main.addLayer(plugin.getChannelDigraphLayer());
-        Main.map.mapView.setActiveLayer(plugin.getChannelDigraphLayer());
+        Main.getLayerManager().setActiveLayer(plugin.getChannelDigraphLayer());
     }
 }
diff --git a/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/JunctionCheckTask.java b/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/JunctionCheckTask.java
index a133220..5e4169d 100644
--- a/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/JunctionCheckTask.java
+++ b/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/JunctionCheckTask.java
@@ -90,6 +90,6 @@ public class JunctionCheckTask extends PleaseWaitRunnable{
         for (int i = 0; i < jc.getSubJunction().size(); i++) {
             plugin.getChannelDigraph().addJunctioncandidateChannel(jc.getSubJunction().get(i));
         }
-        Main.map.mapView.setActiveLayer(plugin.getChannelDigraphLayer());
+        Main.getLayerManager().setActiveLayer(plugin.getChannelDigraphLayer());
     }
 }
diff --git a/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/util/RelationProducer.java b/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/util/RelationProducer.java
index 6bb8d89..e319a1d 100644
--- a/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/util/RelationProducer.java
+++ b/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/util/RelationProducer.java
@@ -41,7 +41,7 @@ public class RelationProducer {
                         .getId(), OsmPrimitiveType.WAY));
             }
         }
-        Main.map.mapView.setActiveLayer(plugin.getOsmlayer());
+        Main.getLayerManager().setActiveLayer(plugin.getOsmlayer());
         plugin.getOsmlayer().data.setSelected(ways);
 
         Relation jrelation = new Relation();
diff --git a/mapdust/src/org/openstreetmap/josm/plugins/mapdust/MapdustPlugin.java b/mapdust/src/org/openstreetmap/josm/plugins/mapdust/MapdustPlugin.java
index c7448a6..3ce056b 100644
--- a/mapdust/src/org/openstreetmap/josm/plugins/mapdust/MapdustPlugin.java
+++ b/mapdust/src/org/openstreetmap/josm/plugins/mapdust/MapdustPlugin.java
@@ -362,7 +362,7 @@ public class MapdustPlugin extends Plugin implements LayerChangeListener,
         if (mapdustLayer != null && mapdustLayer.isVisible()) {
             if (event.getButton() == MouseEvent.BUTTON1) {
                 if (event.getClickCount() == 2 && !event.isConsumed()) {
-                    if (Main.map.mapView.getActiveLayer() == getMapdustLayer()) {
+                    if (Main.getLayerManager().getActiveLayer() == getMapdustLayer()) {
                         /* show add bug dialog */
                         MapdustBug bug = mapdustGUI.getSelectedBug();
                         if (bug != null) {
@@ -619,12 +619,7 @@ public class MapdustPlugin extends Plugin implements LayerChangeListener,
      * <code>MapdustLayer</code> false otherwise
      */
     private boolean containsMapdustLayer() {
-        boolean contains = false;
-        List<Layer> all = Main.map.mapView.getAllLayersAsList();
-        if (mapdustLayer != null && all.contains(mapdustLayer)) {
-            contains = true;
-        }
-        return contains;
+        return mapdustLayer != null && Main.getLayerManager().containsLayer(mapdustLayer);
     }
 
     /**
diff --git a/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java b/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
index 2671966..b23d77c 100644
--- a/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
+++ b/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
@@ -110,8 +110,8 @@ public final class MapillaryLayer extends AbstractModifiableLayer implements
       Main.map.mapView.addLayer(this);
       MapView.addEditLayerChangeListener(this, false);
       MapView.addLayerChangeListener(this);
-      if (Main.map.mapView.getEditLayer() != null)
-        Main.map.mapView.getEditLayer().data.addDataSetListener(this);
+      if (Main.getLayerManager().getEditLayer() != null)
+        Main.getLayerManager().getEditLayer().data.addDataSetListener(this);
       if (MapillaryDownloader.getMode() == MapillaryDownloader.MODES.Automatic)
         MapillaryDownloader.automaticDownload();
       if (MapillaryDownloader.getMode() == MapillaryDownloader.MODES.Semiautomatic)
@@ -222,8 +222,8 @@ public final class MapillaryLayer extends AbstractModifiableLayer implements
     Main.map.mapView.removeMouseListener(this.mode);
     Main.map.mapView.removeMouseMotionListener(this.mode);
     MapView.removeEditLayerChangeListener(this);
-    if (Main.map.mapView.getEditLayer() != null)
-      Main.map.mapView.getEditLayer().data.removeDataSetListener(this);
+    if (Main.getLayerManager().getEditLayer() != null)
+      Main.getLayerManager().getEditLayer().data.removeDataSetListener(this);
     clearInstance();
     super.destroy();
   }
@@ -285,7 +285,7 @@ public final class MapillaryLayer extends AbstractModifiableLayer implements
   @Override
   public synchronized void paint(final Graphics2D g, final MapView mv, final Bounds box) {
     g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
-    if (Main.map.mapView.getActiveLayer() == this) {
+    if (Main.getLayerManager().getActiveLayer() == this) {
       // paint remainder
       g.setPaint(this.hatched);
       g.fill(MapViewGeometryUtil.getNonDownloadedArea(mv, this.data.getBounds()));
@@ -322,7 +322,7 @@ public final class MapillaryLayer extends AbstractModifiableLayer implements
     if (selectedImage != null && selectedImage.getSequence() != null) {
       selectedImageKey = selectedImage.getSequence().getKey();
     }
-    g.setStroke(new BasicStroke(this == Main.map.mapView.getActiveLayer() ? 3 : 2));
+    g.setStroke(new BasicStroke(this == Main.getLayerManager().getActiveLayer() ? 3 : 2));
     for (MapillarySequence seq : getData().getSequences()) {
       if (selectedImageKey != null && selectedImageKey.equals(seq.getKey())) {
         g.setColor(Color.MAGENTA.brighter());
diff --git a/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryDownloadAction.java b/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryDownloadAction.java
index e957b1d..add64d0 100644
--- a/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryDownloadAction.java
+++ b/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryDownloadAction.java
@@ -47,9 +47,9 @@ public class MapillaryDownloadAction extends JosmAction {
       return;
     }
     // Successive calls to this action toggle the active layer between the OSM data layer and the mapillary layer
-    Main.map.mapView.setActiveLayer(
-        Main.map.mapView.getActiveLayer() == MapillaryLayer.getInstance()
-          ? Main.map.mapView.getEditLayer()
+    Main.getLayerManager().setActiveLayer(
+        Main.getLayerManager().getActiveLayer() == MapillaryLayer.getInstance()
+          ? Main.getLayerManager().getEditLayer()
           : MapillaryLayer.getInstance()
     );
   }
diff --git a/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java b/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java
index 06a8a5a..b3b22ee 100644
--- a/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java
+++ b/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java
@@ -151,7 +151,7 @@ public final class MapillaryDownloader {
    */
   public static void automaticDownload() {
     MapillaryLayer layer = MapillaryLayer.getInstance();
-    if (Main.map.mapView.getEditLayer() == null)
+    if (Main.getLayerManager().getEditLayer() == null)
       return;
     if (isAreaTooBig()) {
       tooBigErrorDialog();
@@ -159,7 +159,7 @@ public final class MapillaryDownloader {
     }
     if (getMode() != MODES.Automatic)
       throw new IllegalStateException("Must be in automatic mode.");
-    for (Bounds bounds : Main.map.mapView.getEditLayer().data
+    for (Bounds bounds : Main.getLayerManager().getEditLayer().data
         .getDataSourceBounds()) {
       if (!layer.getData().getBounds().contains(bounds)) {
         layer.getData().getBounds().add(bounds);
@@ -176,7 +176,7 @@ public final class MapillaryDownloader {
    */
   private static boolean isAreaTooBig() {
     double area = 0;
-    for (Bounds bounds : Main.map.mapView.getEditLayer().data.getDataSourceBounds()) {
+    for (Bounds bounds : Main.getLayerManager().getEditLayer().data.getDataSourceBounds()) {
       area += bounds.getArea();
     }
     return area > MAX_AREA;
diff --git a/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/JoinMode.java b/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/JoinMode.java
index 0ede5ef..ae672fb 100644
--- a/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/JoinMode.java
+++ b/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/JoinMode.java
@@ -70,7 +70,7 @@ public class JoinMode extends AbstractMode {
   @Override
   public void mouseMoved(MouseEvent e) {
     this.lastPos = e;
-    if (!(Main.map.mapView.getActiveLayer() instanceof MapillaryLayer))
+    if (!(Main.getLayerManager().getActiveLayer() instanceof MapillaryLayer))
       return;
     MapillaryAbstractImage closestTemp = getClosest(e.getPoint());
     this.data.setHighlightedImage(closestTemp);
diff --git a/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java b/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java
index 8c9edd9..64285cb 100644
--- a/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java
+++ b/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java
@@ -51,12 +51,12 @@ public class SelectMode extends AbstractMode {
     if (e.getButton() != MouseEvent.BUTTON1)
       return;
     MapillaryAbstractImage closest = getClosest(e.getPoint());
-    if (!(Main.map.mapView.getActiveLayer() instanceof MapillaryLayer)
+    if (!(Main.getLayerManager().getActiveLayer() instanceof MapillaryLayer)
             && closest != null && Main.map.mapMode == Main.map.mapModeSelect) {
       this.lastClicked = this.closest;
       this.data.setSelectedImage(closest);
       return;
-    } else if (Main.map.mapView.getActiveLayer() != MapillaryLayer
+    } else if (Main.getLayerManager().getActiveLayer() != MapillaryLayer
             .getInstance())
       return;
     // Double click
@@ -97,7 +97,7 @@ public class SelectMode extends AbstractMode {
 
   @Override
   public void mouseDragged(MouseEvent e) {
-    if (Main.map.mapView.getActiveLayer() != MapillaryLayer.getInstance()) {
+    if (Main.getLayerManager().getActiveLayer() != MapillaryLayer.getInstance()) {
       return;
     }
 
@@ -155,7 +155,7 @@ public class SelectMode extends AbstractMode {
    */
   @Override
   public void mouseMoved(MouseEvent e) {
-    if (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
+    if (Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer
             && Main.map.mapMode != Main.map.mapModeSelect) {
       return;
     }
@@ -166,22 +166,22 @@ public class SelectMode extends AbstractMode {
     MapillaryAbstractImage closestTemp = getClosest(e.getPoint());
 
     if (closestTemp != null
-            && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
+            && Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer
             && !this.imageHighlighted) {
       Main.map.mapMode.putValue("active", Boolean.FALSE);
       this.imageHighlighted = true;
 
     } else if (closestTemp == null
-            && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
+            && Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer
             && this.imageHighlighted && this.nothingHighlighted) {
       this.nothingHighlighted = false;
       Main.map.mapMode.putValue("active", Boolean.TRUE);
 
     } else if (this.imageHighlighted && !this.nothingHighlighted
-            && Main.map.mapView.getEditLayer().data != null
-            && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer) {
+            && Main.getLayerManager().getEditLayer().data != null
+            && Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer) {
 
-      for (OsmPrimitive primivitive : Main.map.mapView.getEditLayer().data
+      for (OsmPrimitive primivitive : Main.getLayerManager().getEditLayer().data
               .allPrimitives()) {
         primivitive.setHighlighted(false);
       }
diff --git a/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementLayer.java b/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementLayer.java
index be5afb7..0db4910 100644
--- a/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementLayer.java
+++ b/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementLayer.java
@@ -233,7 +233,7 @@ public class MeasurementLayer extends Layer {
         public void actionPerformed(ActionEvent e) {
             Box panel = Box.createVerticalBox();
             final JList<GpxLayer> layerList = new JList<>(model);
-            Collection<Layer> data = Main.map.mapView.getAllLayers();
+            Collection<Layer> data = Main.getLayerManager().getLayers();
             Layer lastLayer = null;
             int layerCnt = 0;
 
diff --git a/opendata/src/org/openstreetmap/josm/plugins/opendata/core/layers/OdDataLayer.java b/opendata/src/org/openstreetmap/josm/plugins/opendata/core/layers/OdDataLayer.java
index 6a27cd6..4a6d5f2 100644
--- a/opendata/src/org/openstreetmap/josm/plugins/opendata/core/layers/OdDataLayer.java
+++ b/opendata/src/org/openstreetmap/josm/plugins/opendata/core/layers/OdDataLayer.java
@@ -91,7 +91,7 @@ public class OdDataLayer extends OsmDataLayer implements OdLayer, LayerChangeLis
             DataSet dataSet = new DataSet();
             final OdOsmDataLayer layer = new OdOsmDataLayer(this, dataSet, getName()+"/OSM");
             addOsmLayer(layer);
-            Main.map.mapView.setActiveLayer(osmLayer);
+            Main.getLayerManager().setActiveLayer(osmLayer);
             if (oapiReq != null) {
                 OsmDownloader.downloadOapi(oapiReq);
                 // Overpass API does not allow to exclude tags :(
@@ -173,6 +173,6 @@ public class OdDataLayer extends OsmDataLayer implements OdLayer, LayerChangeLis
     public void makeDiff() {
         final OdDiffLayer layer = new OdDiffLayer(this, getName()+"/Diff");
         addDiffLayer(layer);
-        Main.map.mapView.setActiveLayer(diffLayer);
+        Main.getLayerManager().setActiveLayer(diffLayer);
     }
 }
diff --git a/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustMapMode.java b/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustMapMode.java
index 69b2697..aa0fcd5 100644
--- a/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustMapMode.java
+++ b/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustMapMode.java
@@ -132,7 +132,7 @@ public class PhotoAdjustMapMode extends MapMode implements LayerChangeListener {
         // Activate the mode only if the current layer is not a
         // GeoImageLayer.  GeoImageLayer's are handled by the plug-in
         // directly.
-        if (! (Main.map.mapView.getActiveLayer() instanceof GeoImageLayer)) {
+        if (! (Main.getLayerManager().getActiveLayer() instanceof GeoImageLayer)) {
             activateMode();
         }
     }
@@ -207,7 +207,7 @@ public class PhotoAdjustMapMode extends MapMode implements LayerChangeListener {
      */
     private boolean hasLayersToAdjust() {
         if (Main.map == null || Main.map.mapView == null) return false;
-        return ! Main.map.mapView.getLayersOfType(GeoImageLayer.class).isEmpty();
+        return ! Main.getLayerManager().getLayersOfType(GeoImageLayer.class).isEmpty();
     }
 
     /**
@@ -216,7 +216,7 @@ public class PhotoAdjustMapMode extends MapMode implements LayerChangeListener {
      * @return list of visible GeoImageLayer's
      */
     private List<GeoImageLayer> getVisibleGeoImageLayers() {
-        List<GeoImageLayer> all = new ArrayList<>(Main.map.mapView.getLayersOfType(GeoImageLayer.class));
+        List<GeoImageLayer> all = new ArrayList<>(Main.getLayerManager().getLayersOfType(GeoImageLayer.class));
         Iterator<GeoImageLayer> it = all.iterator();
         while (it.hasNext()) {
             if (!it.next().isVisible()) it.remove();
diff --git a/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerPlugin.java b/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerPlugin.java
index 11ee943..40648e4 100644
--- a/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerPlugin.java
+++ b/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerPlugin.java
@@ -158,7 +158,7 @@ public class PicLayerPlugin extends Plugin implements LayerChangeListener {
                 new SavePictureCalibrationAction((PicLayerAbstract) arg0).actionPerformed(null);
         }
         // Why should I do all these checks now?
-        boolean enable = Main.map != null && Main.map.mapView != null && Main.map.mapView.getAllLayers() != null && Main.map.mapView.getAllLayers().size() != 0;
+        boolean enable = Main.map != null && Main.map.mapView != null && Main.getLayerManager().getLayers() != null && Main.getLayerManager().getLayers().size() != 0;
         newLayerFromFileAction.setEnabled(enable);
         newLayerFromClipboardAction.setEnabled(enable);
     }
diff --git a/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/GenericPicTransformAction.java b/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/GenericPicTransformAction.java
index 22a08e2..7fa86d4 100644
--- a/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/GenericPicTransformAction.java
+++ b/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/GenericPicTransformAction.java
@@ -56,8 +56,8 @@ public abstract class GenericPicTransformAction extends MapMode implements Mouse
     @Override
     public void mousePressed(MouseEvent e) {
         // Start action
-        if ( Main.map.mapView.getActiveLayer() instanceof PicLayerAbstract ) {
-            currentLayer = (PicLayerAbstract)Main.map.mapView.getActiveLayer();
+        if ( Main.getLayerManager().getActiveLayer() instanceof PicLayerAbstract ) {
+            currentLayer = (PicLayerAbstract)Main.getLayerManager().getActiveLayer();
 
             if ( currentLayer != null && e.getButton() == MouseEvent.BUTTON1 ) {
                 requestFocusInMapView();
@@ -98,7 +98,7 @@ public abstract class GenericPicTransformAction extends MapMode implements Mouse
     }
 
     protected void updateDrawPoints(boolean value) {
-        Layer active = Main.map.mapView.getActiveLayer();
+        Layer active = Main.getLayerManager().getActiveLayer();
         if (active instanceof PicLayerAbstract) {
             ((PicLayerAbstract)active).setDrawPoints(value);
         }
diff --git a/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/newlayer/NewLayerFromFileAction.java b/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/newlayer/NewLayerFromFileAction.java
index 0b94f8f..783af67 100644
--- a/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/newlayer/NewLayerFromFileAction.java
+++ b/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/newlayer/NewLayerFromFileAction.java
@@ -118,8 +118,8 @@ public class NewLayerFromFileAction extends JosmAction {
             // The first loaded layer will be placed at the top of any other layer of the same class,
             // or at the bottom of the stack if there is no such layer yet
             // The next layers we load will be placed one after the other after this first layer
-            int newLayerPos = Main.map.mapView.getAllLayers().size();
-            for(Layer l : Main.map.mapView.getLayersOfType(PicLayerAbstract.class)) {
+            int newLayerPos = Main.getLayerManager().getLayers().size();
+            for(Layer l : Main.getLayerManager().getLayersOfType(PicLayerAbstract.class)) {
                 int pos = Main.map.mapView.getLayerPos(l);
                 if (pos < newLayerPos) newLayerPos = pos;
             }
diff --git a/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/RasterFiltersPlugin.java b/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/RasterFiltersPlugin.java
index 0f65426..3a2a23f 100644
--- a/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/RasterFiltersPlugin.java
+++ b/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/RasterFiltersPlugin.java
@@ -118,7 +118,7 @@ public class RasterFiltersPlugin extends Plugin implements LayerChangeListener {
 			action.removeFiltersDialog(dialog);
 		}
 
-		if (Main.map.mapView.getAllLayersAsList().size() == 0) {
+		if (Main.getLayerManager().getLayers().size() == 0) {
 
 			Container container = filterButton.getParent();
 			if (container != null)
diff --git a/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/actions/ShowLayerFiltersDialog.java b/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/actions/ShowLayerFiltersDialog.java
index 5cc303a..fe91082 100644
--- a/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/actions/ShowLayerFiltersDialog.java
+++ b/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/actions/ShowLayerFiltersDialog.java
@@ -50,7 +50,7 @@ public final class ShowLayerFiltersDialog extends AbstractAction implements Laye
 	@Override
 	public void actionPerformed(ActionEvent e) {
 
-		Layer layer = Main.map.mapView.getActiveLayer();
+		Layer layer = Main.getLayerManager().getActiveLayer();
 
 		if (layer instanceof ImageryLayer) {
 			for (FiltersDialog temp : dialogs) {
diff --git a/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/model/FiltersManager.java b/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/model/FiltersManager.java
index b8c083e..10aa05a 100644
--- a/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/model/FiltersManager.java
+++ b/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/model/FiltersManager.java
@@ -130,7 +130,7 @@ ActionListener, ItemListener {
 		fp.setPreferredSize(new Dimension(300, fp.getNeededHeight()));
 
 		filter.changeFilterState(filterState.encodeJson());
-		Main.map.mapView.getActiveLayer().setFilterStateChanged();
+		Main.getLayerManager().getActiveLayer().setFilterStateChanged();
 
 		fp.createBottomPanel(this);
 
@@ -154,8 +154,8 @@ ActionListener, ItemListener {
 		if (filtersMap.get(filterId) != null)
 			filtersMap.get(filterId).changeFilterState(filterState.encodeJson());
 
-		if (Main.map.mapView.getActiveLayer() != null) {
-			Main.map.mapView.getActiveLayer().setFilterStateChanged();
+		if (Main.getLayerManager().getActiveLayer() != null) {
+			Main.getLayerManager().getActiveLayer().setFilterStateChanged();
 		}
 
 	}
@@ -238,7 +238,7 @@ ActionListener, ItemListener {
 			dialog.getAddButton().setEnabled(true);
 		}
 
-		Main.map.mapView.getActiveLayer().setFilterStateChanged();
+		Main.getLayerManager().getActiveLayer().setFilterStateChanged();
 
 	}
 
@@ -254,14 +254,14 @@ ActionListener, ItemListener {
 			UID filterId = filterPanel.getFilterId();
 			disabledFilters.add(filtersMap.get(filterId));
 
-			Main.map.mapView.getActiveLayer().setFilterStateChanged();
+			Main.getLayerManager().getActiveLayer().setFilterStateChanged();
 
 		} else {
 
 			UID filterId = filterPanel.getFilterId();
 			disabledFilters.remove(filtersMap.get(filterId));
 
-			Main.map.mapView.getActiveLayer().setFilterStateChanged();
+			Main.getLayerManager().getActiveLayer().setFilterStateChanged();
 
 		}
 	}
diff --git a/routes/src/org/openstreetmap/josm/plugins/routes/RoutesPlugin.java b/routes/src/org/openstreetmap/josm/plugins/routes/RoutesPlugin.java
index 83f8c27..ffac4fa 100644
--- a/routes/src/org/openstreetmap/josm/plugins/routes/RoutesPlugin.java
+++ b/routes/src/org/openstreetmap/josm/plugins/routes/RoutesPlugin.java
@@ -78,7 +78,7 @@ public class RoutesPlugin extends Plugin implements LayerChangeListener {
 
     private void checkLayers() {
         if (Main.map != null && Main.map.mapView != null) {
-            for (Layer layer:Main.map.mapView.getAllLayers()) {
+            for (Layer layer:Main.getLayerManager().getLayers()) {
                 if (layer instanceof OsmDataLayer) {
                     if (!isShown) {
                         isShown = true;
diff --git a/routing/src/com/innovant/josm/jrt/core/RoutingGraph.java b/routing/src/com/innovant/josm/jrt/core/RoutingGraph.java
index f0ac693..fba2b2d 100644
--- a/routing/src/com/innovant/josm/jrt/core/RoutingGraph.java
+++ b/routing/src/com/innovant/josm/jrt/core/RoutingGraph.java
@@ -349,7 +349,7 @@ public class RoutingGraph {
         List<OsmEdge> path = new ArrayList<>();
         Graph<Node,OsmEdge> g;
         double totalWeight = 0;
-        RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+        RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
         RoutingModel routingModel = layer.getRoutingModel();
 
         if (graph == null || routingModel.getOnewayChanged())
diff --git a/routing/src/com/innovant/josm/plugin/routing/actions/AddRouteNodeAction.java b/routing/src/com/innovant/josm/plugin/routing/actions/AddRouteNodeAction.java
index ccb59d6..acdb4b5 100644
--- a/routing/src/com/innovant/josm/plugin/routing/actions/AddRouteNodeAction.java
+++ b/routing/src/com/innovant/josm/plugin/routing/actions/AddRouteNodeAction.java
@@ -82,8 +82,8 @@ public class AddRouteNodeAction extends MapMode {
         if (e.getButton() == MouseEvent.BUTTON1) {
             // Search for nearest highway node
             Node node = null;
-            if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
-                RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+            if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
+                RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
                 node = layer.getNearestHighwayNode(e.getPoint());
                 if(node == null) {
                     logger.debug("no selected node");
diff --git a/routing/src/com/innovant/josm/plugin/routing/actions/MoveRouteNodeAction.java b/routing/src/com/innovant/josm/plugin/routing/actions/MoveRouteNodeAction.java
index 10a8d12..55aabd6 100644
--- a/routing/src/com/innovant/josm/plugin/routing/actions/MoveRouteNodeAction.java
+++ b/routing/src/com/innovant/josm/plugin/routing/actions/MoveRouteNodeAction.java
@@ -95,9 +95,9 @@ public class MoveRouteNodeAction extends MapMode {
     @Override public void mousePressed(MouseEvent e) {
         // If left button is pressed
         if (e.getButton() == MouseEvent.BUTTON1) {
-            if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
+            if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
                 requestFocusInMapView();
-                RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+                RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
                 RoutingModel routingModel = layer.getRoutingModel();
                 // Search for the nearest node in the list
                 List<Node> nl = routingModel.getSelectedNodes();
@@ -128,8 +128,8 @@ public class MoveRouteNodeAction extends MapMode {
     }
 
     private void searchAndReplaceNode(Point point) {
-        if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
-            RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+        if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
+            RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
             RoutingModel routingModel = layer.getRoutingModel();
             RoutingDialog routingDialog = RoutingPlugin.getInstance().getRoutingDialog();
             // Search for nearest highway node
diff --git a/routing/src/com/innovant/josm/plugin/routing/actions/RemoveRouteNodeAction.java b/routing/src/com/innovant/josm/plugin/routing/actions/RemoveRouteNodeAction.java
index 0b4193a..50bb001 100644
--- a/routing/src/com/innovant/josm/plugin/routing/actions/RemoveRouteNodeAction.java
+++ b/routing/src/com/innovant/josm/plugin/routing/actions/RemoveRouteNodeAction.java
@@ -83,8 +83,8 @@ public class RemoveRouteNodeAction extends MapMode {
     @Override public void mouseClicked(MouseEvent e) {
         // If left button is clicked
         if (e.getButton() == MouseEvent.BUTTON1) {
-            if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
-                RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+            if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
+                RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
                 RoutingModel routingModel = layer.getRoutingModel();
                 // Search for the nearest node in the list
                 List<Node> nl = routingModel.getSelectedNodes();
diff --git a/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java b/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java
index 792d0b4..2782823 100644
--- a/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java
+++ b/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java
@@ -130,8 +130,8 @@ public class RoutingDialog extends ToggleDialog {
 
     public void refresh() {
         clearNodes();
-        if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
-            RoutingLayer routingLayer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+        if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
+            RoutingLayer routingLayer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
             RoutingModel routingModel = routingLayer.getRoutingModel();
             for (Node n : routingModel.getSelectedNodes()) {
                 addNode(n);
diff --git a/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java b/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java
index c4c24f7..9bd84cd 100644
--- a/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java
+++ b/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java
@@ -92,8 +92,8 @@ public class RoutingMenu extends JMenu {
         rshorter.setSelected(true);
         rshorter.addItemListener(new ItemListener() {
             public void itemStateChanged(ItemEvent e) {
-                if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
-                    RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+                if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
+                    RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
                     RoutingModel routingModel = layer.getRoutingModel();
                     if (e.getStateChange()==ItemEvent.SELECTED) {
                         routingModel.routingGraph.setTypeRoute(RouteType.SHORTEST);
@@ -121,8 +121,8 @@ public class RoutingMenu extends JMenu {
         JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(tr("Ignore oneways"));
         cbmi.addItemListener(new ItemListener() {
             public void itemStateChanged(ItemEvent e) {
-                if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
-                    RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+                if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
+                    RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
                     RoutingModel routingModel = layer.getRoutingModel();
                     if (e.getStateChange()==ItemEvent.SELECTED)
                         routingModel.routingGraph.getRoutingProfile().setOnewayUse(false);
@@ -141,8 +141,8 @@ public class RoutingMenu extends JMenu {
         reverseMI = new JMenuItem(tr("Reverse route"));
         reverseMI.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
-                if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
-                    RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+                if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
+                    RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
                     RoutingModel routingModel = layer.getRoutingModel();
                     routingModel.reverseNodes();
                     Main.map.repaint();
@@ -154,8 +154,8 @@ public class RoutingMenu extends JMenu {
         clearMI = new JMenuItem(tr("Clear route"));
         clearMI.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
-                if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
-                    RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+                if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
+                    RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
                     RoutingModel routingModel = layer.getRoutingModel();
                     // Reset routing nodes and paths
                     routingModel.reset();
@@ -170,8 +170,8 @@ public class RoutingMenu extends JMenu {
         regraphMI.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
 
-                if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
-                    RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+                if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
+                    RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
                     RoutingModel routingModel = layer.getRoutingModel();
                     routingModel.routingGraph.resetGraph();
                     routingModel.routingGraph.createGraph();
diff --git a/sds/src/org/openstreetmap/hot/sds/SdsMenu.java b/sds/src/org/openstreetmap/hot/sds/SdsMenu.java
index c6cadca..5654b23 100644
--- a/sds/src/org/openstreetmap/hot/sds/SdsMenu.java
+++ b/sds/src/org/openstreetmap/hot/sds/SdsMenu.java
@@ -54,7 +54,7 @@ public class SdsMenu extends JMenu implements LayerChangeListener {
     }
 
     void setEnabledState() {
-        boolean en = (Main.map != null) && (Main.map.mapView != null) && (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer);
+        boolean en = (Main.map != null) && (Main.map.mapView != null) && (Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer);
         loadItem.setEnabled(en);
         saveItem.setEnabled(en);
     }
diff --git a/sds/src/org/openstreetmap/hot/sds/SdsSaveAction.java b/sds/src/org/openstreetmap/hot/sds/SdsSaveAction.java
index 5ece685..f2691b3 100644
--- a/sds/src/org/openstreetmap/hot/sds/SdsSaveAction.java
+++ b/sds/src/org/openstreetmap/hot/sds/SdsSaveAction.java
@@ -36,8 +36,8 @@ public class SdsSaveAction extends SdsDiskAccessAction {
 
     public boolean doSave() {
         Layer layer = null;
-        if (Main.isDisplayingMapView() && (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer))
-            layer = Main.map.mapView.getActiveLayer();
+        if (Main.isDisplayingMapView() && (Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer))
+            layer = Main.getLayerManager().getActiveLayer();
 
         if (layer == null)
             return false;
diff --git a/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/SetWaypointAction.java b/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/SetWaypointAction.java
index 832a140..ec2eda4 100644
--- a/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/SetWaypointAction.java
+++ b/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/SetWaypointAction.java
@@ -124,7 +124,7 @@ public class SetWaypointAction extends AbstractSurveyorAction {
      */
     public GpxLayer getGpxLayer() {
         if(liveGpsLayer == null) {
-            Collection<Layer> layers = Main.map.mapView.getAllLayers();
+            Collection<Layer> layers = Main.getLayerManager().getLayers();
             for (Layer layer : layers) {
                 if(layer instanceof LiveGpsLayer) {
                     liveGpsLayer = (LiveGpsLayer) layer;
diff --git a/surveyor/src/at/dallermassl/josm/plugin/surveyor/util/LayerUtil.java b/surveyor/src/at/dallermassl/josm/plugin/surveyor/util/LayerUtil.java
index 3277b97..63e22e4 100644
--- a/surveyor/src/at/dallermassl/josm/plugin/surveyor/util/LayerUtil.java
+++ b/surveyor/src/at/dallermassl/josm/plugin/surveyor/util/LayerUtil.java
@@ -23,7 +23,7 @@ public class LayerUtil {
     public static <LayerType extends Layer> LayerType findGpsLayer(String layerName, Class<LayerType> layerType) {
         Layer result = null;
         if(Main.map != null && Main.map.mapView != null) {
-            for(Layer layer : Main.map.mapView.getAllLayers()) {
+            for(Layer layer : Main.getLayerManager().getLayers()) {
                 if(layerName.equals(layer.getName()) && layerType.isAssignableFrom(layer.getClass())) {
                     result = layer;
                     break;
diff --git a/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditor.java b/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditor.java
index 264d923..617d4d6 100644
--- a/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditor.java
+++ b/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditor.java
@@ -818,7 +818,7 @@ public class TurnRestrictionEditor extends JDialog implements NavigationControle
 
         public void actionPerformed(ActionEvent e) {
             if (Main.main.getActiveLayer() != getLayer()){
-                Main.map.mapView.setActiveLayer(getLayer());
+                Main.getLayerManager().setActiveLayer(getLayer());
             }
             Relation tr = getTurnRestriction();
             if (tr == null || tr.getDataSet() == null) return;
diff --git a/waypoint_search/src/org/openstreetmap/josm/plugins/waypointSearch/Engine.java b/waypoint_search/src/org/openstreetmap/josm/plugins/waypointSearch/Engine.java
index f33a04b..7889d6c 100644
--- a/waypoint_search/src/org/openstreetmap/josm/plugins/waypointSearch/Engine.java
+++ b/waypoint_search/src/org/openstreetmap/josm/plugins/waypointSearch/Engine.java
@@ -17,7 +17,7 @@ class Engine {
         List<Marker> returnList = new ArrayList<>();
         if (gpxLayersExist()) {
             //Loop over marker (waypoint) layers.. it could be more than one
-            for (Iterator<MarkerLayer> it = Main.map.mapView.getLayersOfType(MarkerLayer.class).iterator(); it.hasNext();) {
+            for (Iterator<MarkerLayer> it = Main.getLayerManager().getLayersOfType(MarkerLayer.class).iterator(); it.hasNext();) {
                 //loop over each marker (waypoint)
                 for (Iterator<Marker> markerIterator = it.next().data.iterator(); markerIterator.hasNext();) {
                     Marker marker = markerIterator.next();
@@ -31,6 +31,6 @@ class Engine {
     }   
     
     static boolean gpxLayersExist() {
-        return Main.map != null && Main.map.mapView.hasLayers() && !Main.map.mapView.getLayersOfType(MarkerLayer.class).isEmpty();
+        return Main.map != null && Main.getLayerManager().containsLayers() && !Main.getLayerManager().getLayersOfType(MarkerLayer.class).isEmpty();
     }
 }
