Index: applications/editors/josm/plugins/lakewalker/build.xml
===================================================================
--- applications/editors/josm/plugins/lakewalker/build.xml	(revision 33711)
+++ applications/editors/josm/plugins/lakewalker/build.xml	(revision 33712)
@@ -5,5 +5,5 @@
     <property name="commit.message" value="Changed the constructor signature of the plugin main class"/>
     <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
-    <property name="plugin.main.version" value="10580"/>
+    <property name="plugin.main.version" value="12856"/>
 
     <!-- Configure these properties (replace "..." accordingly).
Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java	(revision 33711)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java	(revision 33712)
@@ -25,9 +25,13 @@
 import org.openstreetmap.josm.command.SequenceCommand;
 import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.PleaseWaitRunnable;
 import org.openstreetmap.josm.gui.progress.ProgressMonitor;
 import org.openstreetmap.josm.tools.ImageProvider;
+import org.openstreetmap.josm.tools.Logging;
 import org.openstreetmap.josm.tools.Shortcut;
 import org.xml.sax.SAXException;
@@ -60,11 +64,12 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        if (Main.map == null || Main.map.mapView == null || active)
+        if (!MainApplication.isDisplayingMapView() || active)
             return;
 
         active = true;
-        oldCursor = Main.map.mapView.getCursor();
-        Main.map.mapView.setCursor(ImageProvider.getCursor("crosshair", "lakewalker-sml"));
-        Main.map.mapView.addMouseListener(this);
+        MapView mapView = MainApplication.getMap().mapView;
+        oldCursor = mapView.getCursor();
+        mapView.setCursor(ImageProvider.getCursor("crosshair", "lakewalker-sml"));
+        mapView.addMouseListener(this);
     }
 
@@ -74,6 +79,6 @@
     */
     private void cleanupCache() {
-        final long maxCacheAge = System.currentTimeMillis()-Main.pref.getInteger(LakewalkerPreferences.PREF_MAXCACHEAGE, 100)*24*60*60*1000L;
-        final long maxCacheSize = Main.pref.getInteger(LakewalkerPreferences.PREF_MAXCACHESIZE, 300)*1024*1024L;
+        final long maxCacheAge = System.currentTimeMillis()-Main.pref.getInt(LakewalkerPreferences.PREF_MAXCACHEAGE, 100)*24*60*60*1000L;
+        final long maxCacheSize = Main.pref.getInt(LakewalkerPreferences.PREF_MAXCACHESIZE, 300)*1024*1024L;
 
         for (String wmsFolder : LakewalkerPreferences.WMSLAYERS) {
@@ -116,18 +121,18 @@
     protected void lakewalk(Point clickPoint) {
         // Positional data
-        final LatLon pos = Main.map.mapView.getLatLon(clickPoint.x, clickPoint.y);
-        final LatLon topLeft = Main.map.mapView.getLatLon(0, 0);
-        final LatLon botRight = Main.map.mapView.getLatLon(Main.map.mapView.getWidth(),
-            Main.map.mapView.getHeight());
+        MapView mapView = MainApplication.getMap().mapView;
+        final LatLon pos = mapView.getLatLon(clickPoint.x, clickPoint.y);
+        final LatLon topLeft = mapView.getLatLon(0, 0);
+        final LatLon botRight = mapView.getLatLon(mapView.getWidth(), mapView.getHeight());
 
         /*
         * Collect options
         */
-        final int waylen = Main.pref.getInteger(LakewalkerPreferences.PREF_MAX_SEG, 500);
-        final int maxnode = Main.pref.getInteger(LakewalkerPreferences.PREF_MAX_NODES, 50000);
-        final int threshold = Main.pref.getInteger(LakewalkerPreferences.PREF_THRESHOLD_VALUE, 90);
+        final int waylen = Main.pref.getInt(LakewalkerPreferences.PREF_MAX_SEG, 500);
+        final int maxnode = Main.pref.getInt(LakewalkerPreferences.PREF_MAX_NODES, 50000);
+        final int threshold = Main.pref.getInt(LakewalkerPreferences.PREF_THRESHOLD_VALUE, 90);
         final double epsilon = Main.pref.getDouble(LakewalkerPreferences.PREF_EPSILON, 0.0003);
-        final int resolution = Main.pref.getInteger(LakewalkerPreferences.PREF_LANDSAT_RES, 4000);
-        final int tilesize = Main.pref.getInteger(LakewalkerPreferences.PREF_LANDSAT_SIZE, 2000);
+        final int resolution = Main.pref.getInt(LakewalkerPreferences.PREF_LANDSAT_RES, 4000);
+        final int tilesize = Main.pref.getInt(LakewalkerPreferences.PREF_LANDSAT_SIZE, 2000);
         final String startdir = Main.pref.get(LakewalkerPreferences.PREF_START_DIR, "east");
         final String wmslayer = Main.pref.get(LakewalkerPreferences.PREF_WMS, "IR1");
@@ -151,5 +156,5 @@
             new Thread(lakewalkerTask).start();
         } catch (Exception ex) {
-            Main.error(ex);
+            Logging.error(ex);
         }
     }
@@ -164,5 +169,5 @@
                         progressMonitor.createSubTaskMonitor(1, false));
             } catch (LakewalkerException e) {
-                Main.error(e);
+                Logging.error(e);
             }
 
@@ -219,4 +224,5 @@
 
             int nodesinway = 0;
+            DataSet ds = getLayerManager().getEditDataSet();
 
             for (int i = 0; i < nodelist.size(); i++) {
@@ -231,5 +237,5 @@
                         fn = n;
                     }
-                    commands.add(new AddCommand(n));
+                    commands.add(new AddCommand(ds, n));
 
                 } catch (Exception ex) {
@@ -239,5 +245,5 @@
                 way.addNode(n);
 
-                if (nodesinway > Main.pref.getInteger(LakewalkerPreferences.PREF_MAX_SEG, 500)) {
+                if (nodesinway > Main.pref.getInt(LakewalkerPreferences.PREF_MAX_SEG, 500)) {
                     String waytype = Main.pref.get(LakewalkerPreferences.PREF_WAYTYPE, "water");
 
@@ -247,5 +253,5 @@
 
                     way.put("source", Main.pref.get(LakewalkerPreferences.PREF_SOURCE, "Landsat"));
-                    commands.add(new AddCommand(way));
+                    commands.add(new AddCommand(ds, way));
 
                     way = new Way();
@@ -269,9 +275,9 @@
             way.addNode(fn);
 
-            commands.add(new AddCommand(way));
+            commands.add(new AddCommand(ds, way));
 
             if (!commands.isEmpty()) {
                 Main.main.undoRedo.add(new SequenceCommand(tr("Lakewalker trace"), commands));
-                getLayerManager().getEditDataSet().setSelected(ways);
+                ds.setSelected(ways);
             } else {
                 System.out.println("Failed");
@@ -293,6 +299,7 @@
         if (active) {
             active = false;
-            Main.map.mapView.removeMouseListener(this);
-            Main.map.mapView.setCursor(oldCursor);
+            MapView mapView = MainApplication.getMap().mapView;
+            mapView.removeMouseListener(this);
+            mapView.setCursor(oldCursor);
             lakewalk(e.getPoint());
         }
Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPlugin.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPlugin.java	(revision 33711)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPlugin.java	(revision 33712)
@@ -7,4 +7,5 @@
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.MainMenu;
 import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
@@ -20,5 +21,5 @@
     public LakewalkerPlugin(PluginInformation info) {
         super(info);
-        MainMenu.add(Main.main.menu.moreToolsMenu, new LakewalkerAction(tr("Lake Walker")));
+        MainMenu.add(MainApplication.getMenu().moreToolsMenu, new LakewalkerAction(tr("Lake Walker")));
     }
 
@@ -29,5 +30,5 @@
 
     public static File getLakewalkerCacheDir() {
-        return new File(Main.pref.getCacheDirectory(), "lakewalkerwms");
+        return new File(Main.pref.getCacheDirectory(true), "lakewalkerwms");
     }
 }
Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPreferences.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPreferences.java	(revision 33711)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPreferences.java	(revision 33712)
@@ -98,10 +98,10 @@
         buildPreferences(prefPanel);
 
-        maxSegsConfig.setValue(Main.pref.getInteger(PREF_MAX_SEG, 500));
-        maxNodesConfig.setValue(Main.pref.getInteger(PREF_MAX_NODES, 50000));
-        thresholdConfig.setValue(Main.pref.getInteger(PREF_THRESHOLD_VALUE, 90));
+        maxSegsConfig.setValue(Main.pref.getInt(PREF_MAX_SEG, 500));
+        maxNodesConfig.setValue(Main.pref.getInt(PREF_MAX_NODES, 50000));
+        thresholdConfig.setValue(Main.pref.getInt(PREF_THRESHOLD_VALUE, 90));
         epsilonConfig.setValue(Main.pref.getDouble(PREF_EPSILON, 0.0003));
-        landsatResConfig.setValue(Main.pref.getInteger(PREF_LANDSAT_RES, 4000));
-        landsatSizeConfig.setValue(Main.pref.getInteger(PREF_LANDSAT_SIZE, 2000));
+        landsatResConfig.setValue(Main.pref.getInt(PREF_LANDSAT_RES, 4000));
+        landsatSizeConfig.setValue(Main.pref.getInt(PREF_LANDSAT_SIZE, 2000));
         eastOffsetConfig.setValue(Main.pref.getDouble(PREF_EAST_OFFSET, 0.0));
         northOffsetConfig.setValue(Main.pref.getDouble(PREF_NORTH_OFFSET, 0.0));
@@ -110,6 +110,6 @@
         wmsConfig.setValue(Main.pref.get(PREF_WMS, "IR1"));
         sourceConfig.setValue(Main.pref.get(PREF_SOURCE, "Landsat"));
-        maxCacheSizeConfig.setValue(Main.pref.getInteger(PREF_MAXCACHESIZE, 300));
-        maxCacheAgeConfig.setValue(Main.pref.getInteger(PREF_MAXCACHEAGE, 100));
+        maxCacheSizeConfig.setValue(Main.pref.getInt(PREF_MAXCACHESIZE, 300));
+        maxCacheAgeConfig.setValue(Main.pref.getInt(PREF_MAXCACHEAGE, 100));
     }
 
