Index: applications/editors/josm/plugins/imagery_offset_db/build.xml
===================================================================
--- applications/editors/josm/plugins/imagery_offset_db/build.xml	(revision 33546)
+++ applications/editors/josm/plugins/imagery_offset_db/build.xml	(revision 33547)
@@ -5,6 +5,6 @@
     <property name="commit.message" value="Imagery Offset Database"/>
     <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
-    <property name="plugin.main.version" value="12093"/>
-	<property name="plugin.canloadatruntime" value="true"/>
+    <property name="plugin.main.version" value="12643"/>
+    <property name="plugin.canloadatruntime" value="true"/>
 
     <property name="plugin.author" value="Ilya Zverev"/>
Index: applications/editors/josm/plugins/imagery_offset_db/src/iodb/CalibrationLayer.java
===================================================================
--- applications/editors/josm/plugins/imagery_offset_db/src/iodb/CalibrationLayer.java	(revision 33546)
+++ applications/editors/josm/plugins/imagery_offset_db/src/iodb/CalibrationLayer.java	(revision 33547)
@@ -19,9 +19,9 @@
 import javax.swing.Icon;
 
-import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.AutoScaleAction;
 import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
@@ -152,11 +152,11 @@
             double lat = 0.0;
             double lon = 0.0;
-            for (int i = 0; i < geometry.length; i++) {
-                lon += geometry[i].lon();
-                lat += geometry[i].lat();
+            for (LatLon ll : geometry) {
+                lon += ll.lon();
+                lat += ll.lat();
             }
             center = new LatLon(lat / geometry.length, lon / geometry.length);
         }
-        Main.map.mapView.zoomTo(center);
+        MainApplication.getMap().mapView.zoomTo(center);
     }
 
@@ -178,5 +178,5 @@
         public void actionPerformed(ActionEvent e) {
             color = c;
-            Main.map.mapView.repaint();
+            MainApplication.getMap().mapView.repaint();
         }
     }
Index: applications/editors/josm/plugins/imagery_offset_db/src/iodb/DeprecateOffsetAction.java
===================================================================
--- applications/editors/josm/plugins/imagery_offset_db/src/iodb/DeprecateOffsetAction.java	(revision 33546)
+++ applications/editors/josm/plugins/imagery_offset_db/src/iodb/DeprecateOffsetAction.java	(revision 33547)
@@ -13,5 +13,7 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.gui.JosmUserIdentityManager;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.tools.ImageProvider;
+import org.openstreetmap.josm.tools.Logging;
 
 /**
@@ -43,5 +45,5 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        if (Main.map == null || Main.map.mapView == null || !Main.map.isVisible())
+        if (!MainApplication.isDisplayingMapView() || !MainApplication.getMap().isVisible())
             return;
 
@@ -98,7 +100,7 @@
                     if (listener != null)
                         depTask.setListener(listener);
-                    Main.worker.submit(depTask);
+                    MainApplication.worker.submit(depTask);
                 } catch (UnsupportedEncodingException ex) {
-                    Main.error(ex);
+                    Logging.error(ex);
                 }
     }
Index: applications/editors/josm/plugins/imagery_offset_db/src/iodb/GetImageryOffsetAction.java
===================================================================
--- applications/editors/josm/plugins/imagery_offset_db/src/iodb/GetImageryOffsetAction.java	(revision 33546)
+++ applications/editors/josm/plugins/imagery_offset_db/src/iodb/GetImageryOffsetAction.java	(revision 33547)
@@ -21,4 +21,5 @@
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.projection.Projection;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer;
 import org.openstreetmap.josm.tools.ImageProvider;
@@ -54,8 +55,8 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        if (Main.map == null || Main.map.mapView == null || !Main.map.isVisible())
+        if (!MainApplication.isDisplayingMapView() || !MainApplication.getMap().isVisible())
             return;
-        Projection proj = Main.map.mapView.getProjection();
-        LatLon center = proj.eastNorth2latlon(Main.map.mapView.getCenter());
+        Projection proj = MainApplication.getMap().mapView.getProjection();
+        LatLon center = proj.eastNorth2latlon(MainApplication.getMap().mapView.getCenter());
         AbstractTileSourceLayer layer = ImageryOffsetTools.getTopImageryLayer();
         String imagery = ImageryOffsetTools.getImageryID(layer);
@@ -64,5 +65,5 @@
 
         DownloadOffsetsTask download = new DownloadOffsetsTask(center, layer, imagery);
-        Main.worker.submit(download);
+        MainApplication.worker.submit(download);
     }
 
@@ -74,5 +75,5 @@
     protected void updateEnabledState() {
         boolean state = true;
-        if (Main.map == null || Main.map.mapView == null || !Main.map.isVisible())
+        if (!MainApplication.isDisplayingMapView() || !MainApplication.getMap().isVisible())
             state = false;
         AbstractTileSourceLayer layer = ImageryOffsetTools.getTopImageryLayer();
Index: applications/editors/josm/plugins/imagery_offset_db/src/iodb/IODBReader.java
===================================================================
--- applications/editors/josm/plugins/imagery_offset_db/src/iodb/IODBReader.java	(revision 33546)
+++ applications/editors/josm/plugins/imagery_offset_db/src/iodb/IODBReader.java	(revision 33547)
@@ -15,4 +15,5 @@
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.io.UTFInputStreamReader;
+import org.openstreetmap.josm.tools.Logging;
 import org.xml.sax.Attributes;
 import org.xml.sax.InputSource;
@@ -163,5 +164,5 @@
                         // On one hand, we don't care, but this situation is one
                         // of those "it can never happen" cases.
-                        System.err.println(ex.getMessage());
+                        Logging.warn(ex);
                     }
                     parsingOffset = false;
Index: applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffset.java
===================================================================
--- applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffset.java	(revision 33546)
+++ applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffset.java	(revision 33547)
@@ -3,11 +3,7 @@
 
 import java.util.Map;
-import org.openstreetmap.josm.Main;
 
 import org.openstreetmap.josm.data.coor.CoordinateFormat;
-import org.openstreetmap.josm.data.coor.EastNorth;
 import org.openstreetmap.josm.data.coor.LatLon;
-import org.openstreetmap.josm.data.imagery.OffsetBookmark;
-import org.openstreetmap.josm.data.projection.Projection;
 
 /**
Index: applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffsetPlugin.java
===================================================================
--- applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffsetPlugin.java	(revision 33546)
+++ applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffsetPlugin.java	(revision 33547)
@@ -12,4 +12,5 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.Version;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences;
 import org.openstreetmap.josm.plugins.Plugin;
@@ -42,6 +43,6 @@
         int version = Version.getInstance().getVersion();
         JMenu offsetMenu = version < 5803
-                ? Main.main.menu.addMenu("Offset", tr("Offset"), KeyEvent.VK_O, 6, "help")
-                        : Main.main.menu.imageryMenu;
+                ? MainApplication.getMenu().addMenu("Offset", tr("Offset"), KeyEvent.VK_O, 6, "help")
+                        : MainApplication.getMenu().imageryMenu;
                 offsetMenu.add(getAction);
                 offsetMenu.add(storeAction);
@@ -53,5 +54,5 @@
                         toolbar.add("getoffset");
                         Main.pref.putCollection("toolbar", toolbar);
-                        Main.toolbar.refreshToolbarControl();
+                        MainApplication.getToolbar().refreshToolbarControl();
                     }
                     Main.pref.put("iodb.modify.toolbar", false);
Index: applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffsetTools.java
===================================================================
--- applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffsetTools.java	(revision 33546)
+++ applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffsetTools.java	(revision 33547)
@@ -12,4 +12,5 @@
 import org.openstreetmap.josm.data.imagery.OffsetBookmark;
 import org.openstreetmap.josm.data.projection.Projection;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer;
@@ -36,7 +37,7 @@
      */
     public static AbstractTileSourceLayer getTopImageryLayer() {
-        if (Main.map == null || Main.map.mapView == null)
+        if (!MainApplication.isDisplayingMapView())
             return null;
-        List<AbstractTileSourceLayer> layers = Main.getLayerManager().getLayersOfType(AbstractTileSourceLayer.class);
+        List<AbstractTileSourceLayer> layers = MainApplication.getLayerManager().getLayersOfType(AbstractTileSourceLayer.class);
         for (AbstractTileSourceLayer layer : layers) {
             String url = layer.getInfo().getUrl();
@@ -54,6 +55,6 @@
     public static LatLon getMapCenter() {
         Projection proj = Main.getProjection();
-        return Main.map == null || Main.map.mapView == null
-                ? new LatLon(0, 0) : proj.eastNorth2latlon(Main.map.mapView.getCenter());
+        return !MainApplication.isDisplayingMapView()
+                ? new LatLon(0, 0) : proj.eastNorth2latlon(MainApplication.getMap().mapView.getCenter());
     }
 
@@ -67,5 +68,5 @@
     public static LatLon getLayerOffset(AbstractTileSourceLayer layer, LatLon center) {
         Projection proj = Main.getProjection();
-        EastNorth offsetCenter = Main.map.mapView.getCenter();
+        EastNorth offsetCenter = MainApplication.getMap().mapView.getCenter();
         EastNorth centerOffset = offsetCenter.add(-layer.getDisplaySettings().getDx(),
                 -layer.getDisplaySettings().getDy());
@@ -121,8 +122,8 @@
 
     public static int getCurrentZoom() {
-        if (Main.map == null || Main.map.mapView == null) {
+        if (!MainApplication.isDisplayingMapView()) {
             return 1;
         }
-        MapView mv = Main.map.mapView;
+        MapView mv = MainApplication.getMap().mapView;
         LatLon topLeft = mv.getLatLon(0, 0);
         LatLon botRight = mv.getLatLon(mv.getWidth(), mv.getHeight());
Index: applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffsetWatcher.java
===================================================================
--- applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffsetWatcher.java	(revision 33546)
+++ applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffsetWatcher.java	(revision 33547)
@@ -15,4 +15,5 @@
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.imagery.OffsetBookmark;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener;
@@ -51,6 +52,6 @@
         maxDistance = Main.pref.getDouble("iodb.offset.radius", 15);
         MapView.addZoomChangeListener(this);
-        Main.getLayerManager().addLayerChangeListener(this);
-        Main.getLayerManager().addActiveLayerChangeListener(this);
+        MainApplication.getLayerManager().addLayerChangeListener(this);
+        MainApplication.getLayerManager().addActiveLayerChangeListener(this);
         checkOffset(); // we assume there's at the most one imagery layer at this moment
         time = new Timer();
@@ -64,6 +65,6 @@
     public void destroy() {
         MapView.removeZoomChangeListener(this);
-        Main.getLayerManager().removeLayerChangeListener(this);
-        Main.getLayerManager().removeActiveLayerChangeListener(this);
+        MainApplication.getLayerManager().removeLayerChangeListener(this);
+        MainApplication.getLayerManager().removeActiveLayerChangeListener(this);
         time.cancel();
     }
Index: applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetDialog.java
===================================================================
--- applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetDialog.java	(revision 33546)
+++ applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetDialog.java	(revision 33547)
@@ -38,4 +38,5 @@
 import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.gui.JosmUserIdentityManager;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener;
@@ -154,5 +155,5 @@
         }
         pack();
-        Main.map.mapView.repaint();
+        MainApplication.getMap().mapView.repaint();
     }
 
@@ -223,6 +224,6 @@
         MapView.addZoomChangeListener(this);
         if (!MODAL) {
-            Main.map.mapView.addTemporaryLayer(this);
-            Main.map.mapView.repaint();
+            MainApplication.getMap().mapView.addTemporaryLayer(this);
+            MainApplication.getMap().mapView.repaint();
         }
         setVisible(true);
@@ -252,6 +253,6 @@
         if (!MODAL) {
             if (closeDialog) {
-                Main.map.mapView.removeTemporaryLayer(this);
-                Main.map.mapView.repaint();
+                MainApplication.getMap().mapView.removeTemporaryLayer(this);
+                MainApplication.getMap().mapView.repaint();
             }
             if (selectedOffset != null) {
@@ -273,5 +274,5 @@
             ImageryOffsetTools.applyLayerOffset(layer, (ImageryOffset) selectedOffset);
             ImageryOffsetWatcher.getInstance().markGood();
-            Main.map.repaint();
+            MainApplication.getMap().repaint();
             if (!Main.pref.getBoolean("iodb.offset.message", false)) {
                 JOptionPane.showMessageDialog(Main.parent,
@@ -284,5 +285,5 @@
         } else if (selectedOffset instanceof CalibrationObject) {
             CalibrationLayer clayer = new CalibrationLayer((CalibrationObject) selectedOffset);
-            Main.getLayerManager().addLayer(clayer);
+            MainApplication.getLayerManager().addLayer(clayer);
             clayer.panToCenter();
             if (!Main.pref.getBoolean("iodb.calibration.message", false)) {
Index: applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetInfoAction.java
===================================================================
--- applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetInfoAction.java	(revision 33546)
+++ applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetInfoAction.java	(revision 33547)
@@ -13,5 +13,7 @@
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.tools.ImageProvider;
+import org.openstreetmap.josm.tools.Logging;
 
 /**
@@ -61,7 +63,7 @@
                         SimpleOffsetQueryTask reportTask =
                                 new SimpleOffsetQueryTask(query, tr("Reporting the offset..."));
-                        Main.worker.submit(reportTask);
+                        MainApplication.worker.submit(reportTask);
                     } catch (UnsupportedEncodingException ex) {
-                        Main.error(ex);
+                        Logging.error(ex);
                     }
                 }
Index: applications/editors/josm/plugins/imagery_offset_db/src/iodb/StoreImageryOffsetAction.java
===================================================================
--- applications/editors/josm/plugins/imagery_offset_db/src/iodb/StoreImageryOffsetAction.java	(revision 33546)
+++ applications/editors/josm/plugins/imagery_offset_db/src/iodb/StoreImageryOffsetAction.java	(revision 33547)
@@ -20,5 +20,7 @@
 import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.gui.JosmUserIdentityManager;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer;
+import org.openstreetmap.josm.tools.Logging;
 
 /**
@@ -49,5 +51,5 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        if (Main.map == null || Main.map.mapView == null)
+        if (!MainApplication.isDisplayingMapView())
             return;
 
@@ -126,7 +128,7 @@
                 query.append(key).append('=').append(URLEncoder.encode(params.get(key), "UTF8"));
             }
-            Main.worker.submit(new SimpleOffsetQueryTask(query.toString(), tr("Uploading a new offset...")));
+            MainApplication.worker.submit(new SimpleOffsetQueryTask(query.toString(), tr("Uploading a new offset...")));
         } catch (UnsupportedEncodingException ex) {
-            Main.error(ex);
+            Logging.error(ex);
         }
     }
@@ -167,5 +169,5 @@
     protected void updateEnabledState() {
         boolean state = true;
-        if (Main.map == null || Main.map.mapView == null || !Main.map.isVisible())
+        if (!MainApplication.isDisplayingMapView() || !MainApplication.getMap().isVisible())
             state = false;
         if (ImageryOffsetTools.getTopImageryLayer() == null)
