Index: trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java	(revision 12630)
@@ -160,6 +160,6 @@
         // list all imagery entries where the current map location
         // is within the imagery bounds
-        if (Main.isDisplayingMapView()) {
-            MapView mv = Main.map.mapView;
+        if (MainApplication.isDisplayingMapView()) {
+            MapView mv = MainApplication.getMap().mapView;
             LatLon pos = mv.getProjection().eastNorth2latlon(mv.getCenter());
             final List<ImageryInfo> inViewLayers = new ArrayList<>();
Index: trunk/src/org/openstreetmap/josm/gui/MainApplication.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 12630)
@@ -106,4 +106,9 @@
     private static final List<String> COMMAND_LINE_ARGS = new ArrayList<>();
 
+    /**
+     * The MapFrame.
+     */
+    static MapFrame map;
+
     private final MainFrame mainFrame;
 
@@ -225,4 +230,30 @@
     public static List<String> getCommandLineArgs() {
         return Collections.unmodifiableList(COMMAND_LINE_ARGS);
+    }
+
+    /**
+     * Returns the MapFrame.
+     * <p>
+     * There should be no need to access this to access any map data. Use {@link #layerManager} instead.
+     * @return the MapFrame
+     * @see MainPanel
+     * @since 12630 (as a replacement to {@code Main.map})
+     */
+    public static MapFrame getMap() {
+        return map;
+    }
+
+    /**
+     * Replies true if JOSM currently displays a map view. False, if it doesn't, i.e. if
+     * it only shows the MOTD panel.
+     * <p>
+     * You do not need this when accessing the layer manager. The layer manager will be empty if no map view is shown.
+     *
+     * @return <code>true</code> if JOSM currently displays a map view
+     * @since 12630 (as a replacement to {@code Main.isDisplayingMapView()})
+     */
+    @SuppressWarnings("deprecation")
+    public static boolean isDisplayingMapView() {
+        return map != null && map.mapView != null;
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/MainPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/MainPanel.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/MainPanel.java	(revision 12630)
@@ -44,4 +44,5 @@
      * @param showMap If the map should be displayed.
      */
+    @SuppressWarnings("deprecation")
     protected synchronized void updateContent(boolean showMap) {
         GuiHelper.assertCallFromEdt();
@@ -65,4 +66,5 @@
             map = null;
             Main.map = map;
+            MainApplication.map = map;
             add(getGettingStarted(), BorderLayout.CENTER);
         }
@@ -83,8 +85,10 @@
     }
 
+    @SuppressWarnings("deprecation")
     private MapFrame createNewMapFrame() {
         MapFrame mapFrame = new MapFrame(null);
         // Required by many components.
         Main.map = mapFrame;
+        MainApplication.map = mapFrame;
 
         mapFrame.fillPanel(this);
Index: trunk/src/org/openstreetmap/josm/gui/MapMover.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/MapMover.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/MapMover.java	(revision 12630)
@@ -169,8 +169,9 @@
         boolean allowMovement = (e.getModifiersEx() & (MouseEvent.BUTTON3_DOWN_MASK | offMask)) == MouseEvent.BUTTON3_DOWN_MASK;
         if (Main.isPlatformOsx()) {
+            MapFrame map = MainApplication.getMap();
             int macMouseMask = MouseEvent.CTRL_DOWN_MASK | MouseEvent.BUTTON1_DOWN_MASK;
             boolean macMovement = e.getModifiersEx() == macMouseMask;
-            boolean allowedMode = !Main.map.mapModeSelect.equals(Main.map.mapMode)
-                              || SelectAction.Mode.SELECT.equals(Main.map.mapModeSelect.getMode());
+            boolean allowedMode = !map.mapModeSelect.equals(map.mapMode)
+                              || SelectAction.Mode.SELECT.equals(map.mapModeSelect.getMode());
             allowMovement |= macMovement && allowedMode;
         }
Index: trunk/src/org/openstreetmap/josm/gui/MapStatus.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/MapStatus.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/MapStatus.java	(revision 12630)
@@ -406,5 +406,5 @@
                     try {
                         final MouseState ms = incomingMouseState.take();
-                        if (parent != Main.map)
+                        if (parent != MainApplication.getMap())
                             return; // exit, if new parent.
 
Index: trunk/src/org/openstreetmap/josm/gui/MapView.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/MapView.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/MapView.java	(revision 12630)
@@ -562,8 +562,9 @@
         }
 
+        MapFrame map = MainApplication.getMap();
         if (AutoFilterManager.getInstance().getCurrentAutoFilter() != null) {
             AutoFilterManager.getInstance().drawOSDText(tempG);
-        } else if (Main.isDisplayingMapView() && Main.map.filterDialog != null) {
-            Main.map.filterDialog.drawOSDText(tempG);
+        } else if (MainApplication.isDisplayingMapView() && map.filterDialog != null) {
+            map.filterDialog.drawOSDText(tempG);
         }
 
@@ -660,5 +661,6 @@
     @Override
     public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
-        if (Main.map != null) {
+        MapFrame map = MainApplication.getMap();
+        if (map != null) {
             /* This only makes the buttons look disabled. Disabling the actions as well requires
              * the user to re-select the tool after i.e. moving a layer. While testing I found
@@ -666,5 +668,5 @@
              * order. This way it works as visual clue for new users */
             // FIXME: This does not belong here.
-            for (final AbstractButton b: Main.map.allMapModeButtons) {
+            for (final AbstractButton b: map.allMapModeButtons) {
                 MapMode mode = (MapMode) b.getAction();
                 final boolean activeLayerSupported = mode.layerIsSupported(layerManager.getActiveLayer());
Index: trunk/src/org/openstreetmap/josm/gui/NotificationManager.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/NotificationManager.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/NotificationManager.java	(revision 12630)
@@ -114,9 +114,10 @@
                 int x;
                 int y;
-                if (Main.isDisplayingMapView() && Main.map.mapView.getHeight() > 0) {
-                    MapView mv = Main.map.mapView;
+                MapFrame map = MainApplication.getMap();
+                if (MainApplication.isDisplayingMapView() && map.mapView.getHeight() > 0) {
+                    MapView mv = map.mapView;
                     Point mapViewPos = SwingUtilities.convertPoint(mv.getParent(), mv.getX(), mv.getY(), Main.parent);
                     x = mapViewPos.x + margin;
-                    y = mapViewPos.y + mv.getHeight() - Main.map.statusLine.getHeight() - size.height - margin;
+                    y = mapViewPos.y + mv.getHeight() - map.statusLine.getHeight() - size.height - margin;
                 } else {
                     x = margin;
Index: trunk/src/org/openstreetmap/josm/gui/SelectionManager.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/SelectionManager.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/SelectionManager.java	(revision 12630)
@@ -184,5 +184,5 @@
     public void mousePressed(MouseEvent e) {
         if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() > 1 && Main.getLayerManager().getEditDataSet() != null) {
-            SelectByInternalPointAction.performSelection(Main.map.mapView.getEastNorth(e.getX(), e.getY()),
+            SelectByInternalPointAction.performSelection(MainApplication.getMap().mapView.getEastNorth(e.getX(), e.getY()),
                     (e.getModifiersEx() & MouseEvent.SHIFT_DOWN_MASK) != 0,
                     (e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0);
Index: trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterButton.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterButton.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterButton.java	(revision 12630)
@@ -11,7 +11,7 @@
 import javax.swing.JButton;
 
-import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.JosmAction;
 import org.openstreetmap.josm.data.preferences.ColorProperty;
+import org.openstreetmap.josm.gui.MainApplication;
 
 /**
@@ -36,5 +36,5 @@
                 if (filter.equals(afm.getCurrentAutoFilter())) {
                     afm.setCurrentAutoFilter(null);
-                    Main.map.filterDialog.getFilterModel().executeFilters();
+                    MainApplication.getMap().filterDialog.getFilterModel().executeFilters();
                 } else {
                     afm.setCurrentAutoFilter(filter);
Index: trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterManager.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterManager.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterManager.java	(revision 12630)
@@ -43,6 +43,8 @@
 import org.openstreetmap.josm.data.preferences.BooleanProperty;
 import org.openstreetmap.josm.data.preferences.StringProperty;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.MapFrame.MapModeChangeListener;
+import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.NavigatableComponent;
 import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener;
@@ -130,6 +132,7 @@
 
     private synchronized void updateButtons() {
-        if (enabledRule != null && Main.map != null
-                && enabledRule.getMinZoomLevel() <= Selector.GeneralSelector.scale2level(Main.map.mapView.getDist100Pixel())) {
+        MapFrame map = MainApplication.getMap();
+        if (enabledRule != null && map != null
+                && enabledRule.getMinZoomLevel() <= Selector.GeneralSelector.scale2level(map.mapView.getDist100Pixel())) {
             // Retrieve the values from current rule visible on screen
             NavigableSet<String> values = getNumericValues(enabledRule.getKey(), enabledRule.getValueComparator());
@@ -148,4 +151,5 @@
         int i = 0;
         int maxWidth = 16;
+        MapView mapView = MainApplication.getMap().mapView;
         for (final String value : values.descendingSet()) {
             Filter filter = new Filter();
@@ -161,15 +165,15 @@
             buttons.put(value, button);
             maxWidth = Math.max(maxWidth, button.getPreferredSize().width);
-            Main.map.mapView.add(button).setLocation(3, 60 + 22*i++);
+            mapView.add(button).setLocation(3, 60 + 22*i++);
         }
         for (AutoFilterButton b : buttons.values()) {
             b.setSize(maxWidth, 20);
         }
-        Main.map.mapView.validate();
+        mapView.validate();
     }
 
     private void removeAllButtons() {
         for (Iterator<String> it = buttons.keySet().iterator(); it.hasNext();) {
-            Main.map.mapView.remove(buttons.get(it.next()));
+            MainApplication.getMap().mapView.remove(buttons.get(it.next()));
             it.remove();
         }
@@ -193,5 +197,5 @@
         Set<String> values = new TreeSet<>();
         if (ds != null) {
-            BBox bbox = Main.map.mapView.getState().getViewArea().getLatLonBoundsBox().toBBox();
+            BBox bbox = MainApplication.getMap().mapView.getState().getViewArea().getLatLonBoundsBox().toBBox();
             Consumer<OsmPrimitive> consumer = getTagValuesConsumer(key, values);
             ds.searchNodes(bbox).forEach(consumer);
@@ -388,6 +392,7 @@
         setCurrentAutoFilter(null);
         removeAllButtons();
-        if (Main.map != null) {
-            Main.map.filterDialog.getFilterModel().executeFilters();
+        MapFrame map = MainApplication.getMap();
+        if (map != null) {
+            map.filterDialog.getFilterModel().executeFilters();
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java	(revision 12630)
@@ -42,4 +42,5 @@
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.SideButton;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
@@ -463,5 +464,5 @@
                 break;
             }
-            Main.map.repaint();
+            MainApplication.getMap().repaint();
         }
 
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java	(revision 12630)
@@ -56,4 +56,5 @@
 import org.openstreetmap.josm.gui.HelpAwareOptionPane;
 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.NavigatableComponent;
 import org.openstreetmap.josm.gui.OsmPrimitivRenderer;
@@ -130,5 +131,5 @@
             lstConflicts.addMouseListener(new MouseEventHandler());
         }
-        addListSelectionListener(e -> Main.map.mapView.repaint());
+        addListSelectionListener(e -> MainApplication.getMap().mapView.repaint());
 
         SideButton btnResolve = new SideButton(actResolve);
@@ -210,5 +211,5 @@
             lstConflicts.setSelectedIndex(index);
         }
-        Main.map.mapView.repaint();
+        MainApplication.getMap().mapView.repaint();
     }
 
@@ -632,5 +633,5 @@
                 );
                 unfurlDialog();
-                Main.map.repaint();
+                MainApplication.getMap().repaint();
             });
         }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java	(revision 12630)
@@ -40,4 +40,5 @@
 import org.openstreetmap.josm.data.osm.event.TagsChangedEvent;
 import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.MapFrame.MapModeChangeListener;
@@ -88,5 +89,5 @@
         MapFrame.removeMapModeChangeListener(this);
         filterModel.model.clearFilterFlags();
-        Main.map.mapView.repaint();
+        MainApplication.getMap().mapView.repaint();
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/FilterTableModel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/FilterTableModel.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/FilterTableModel.java	(revision 12630)
@@ -11,8 +11,9 @@
 import javax.swing.table.AbstractTableModel;
 
-import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.osm.Filter;
 import org.openstreetmap.josm.data.osm.FilterModel;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.autofilter.AutoFilterManager;
 import org.openstreetmap.josm.gui.widgets.OSDLabel;
@@ -87,6 +88,7 @@
 
     private void updateMap() {
-        if (Main.map != null && model.isChanged()) {
-            Main.map.filterDialog.updateDialogHeader();
+        MapFrame map = MainApplication.getMap();
+        if (map != null && model.isChanged()) {
+            map.filterDialog.updateDialogHeader();
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java	(revision 12630)
@@ -26,4 +26,5 @@
 import org.openstreetmap.josm.gui.DefaultNameFormatter;
 import org.openstreetmap.josm.gui.ExtendedDialog;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.NavigatableComponent;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
@@ -116,5 +117,5 @@
         final Collection<OsmPrimitive> sel = Main.getLayerManager().getEditDataSet().getAllSelected();
         ElemStyles elemstyles = MapPaintStyles.getStyles();
-        NavigatableComponent nc = Main.map.mapView;
+        NavigatableComponent nc = MainApplication.getMap().mapView;
         double scale = nc.getDist100Pixel();
 
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java	(revision 12630)
@@ -44,4 +44,6 @@
 import org.openstreetmap.josm.actions.MergeLayerAction;
 import org.openstreetmap.josm.data.preferences.AbstractProperty;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.SideButton;
@@ -507,5 +509,5 @@
             Layer layer = (Layer) value;
             if (layer instanceof NativeScaleLayer) {
-                boolean active = ((NativeScaleLayer) layer) == Main.map.mapView.getNativeScaleLayer();
+                boolean active = ((NativeScaleLayer) layer) == MainApplication.getMap().mapView.getNativeScaleLayer();
                 cb.setSelected(active);
                 cb.setToolTipText(active
@@ -824,9 +826,10 @@
             List<Integer> sel = getSelectedRows();
             List<Layer> layers = getLayers();
+            MapView mapView = MainApplication.getMap().mapView;
             for (int row : sel) {
                 Layer l1 = layers.get(row);
                 Layer l2 = layers.get(row-1);
-                Main.map.mapView.moveLayer(l2, row);
-                Main.map.mapView.moveLayer(l1, row-1);
+                mapView.moveLayer(l2, row);
+                mapView.moveLayer(l1, row-1);
             }
             fireTableDataChanged();
@@ -859,9 +862,10 @@
             Collections.reverse(sel);
             List<Layer> layers = getLayers();
+            MapView mapView = MainApplication.getMap().mapView;
             for (int row : sel) {
                 Layer l1 = layers.get(row);
                 Layer l2 = layers.get(row+1);
-                Main.map.mapView.moveLayer(l1, row+1);
-                Main.map.mapView.moveLayer(l2, row);
+                mapView.moveLayer(l1, row+1);
+                mapView.moveLayer(l2, row);
             }
             fireTableDataChanged();
@@ -999,9 +1003,10 @@
                     break;
                 case 1:
-                    NativeScaleLayer oldLayer = Main.map.mapView.getNativeScaleLayer();
+                    MapFrame map = MainApplication.getMap();
+                    NativeScaleLayer oldLayer = map.mapView.getNativeScaleLayer();
                     if (oldLayer == l) {
-                        Main.map.mapView.setNativeScaleLayer(null);
+                        map.mapView.setNativeScaleLayer(null);
                     } else if (l instanceof NativeScaleLayer) {
-                        Main.map.mapView.setNativeScaleLayer((NativeScaleLayer) l);
+                        map.mapView.setNativeScaleLayer((NativeScaleLayer) l);
                         if (oldLayer != null) {
                             int idx = getLayers().indexOf(oldLayer);
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/MinimapDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/MinimapDialog.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/MinimapDialog.java	(revision 12630)
@@ -8,6 +8,6 @@
 import java.util.Collections;
 
-import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.Bounds;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.NavigatableComponent;
@@ -55,6 +55,6 @@
     @Override
     public void zoomChanged() {
-        if (!skipEvents && Main.isDisplayingMapView()) {
-            MapView mv = Main.map.mapView;
+        if (!skipEvents && MainApplication.isDisplayingMapView()) {
+            MapView mv = MainApplication.getMap().mapView;
             final Bounds currentBounds = new Bounds(
                     mv.getLatLon(0, mv.getHeight()),
@@ -72,5 +72,5 @@
         if (!skipEvents) {
             skipEvents = true;
-            Main.map.mapView.zoomTo(slippyMap.getBoundingBox());
+            MainApplication.getMap().mapView.zoomTo(slippyMap.getBoundingBox());
             skipEvents = false;
         }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java	(revision 12630)
@@ -36,4 +36,6 @@
 import org.openstreetmap.josm.data.notes.NoteComment;
 import org.openstreetmap.josm.data.osm.NoteData;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.NoteInputDialog;
 import org.openstreetmap.josm.gui.NoteSortDialog;
@@ -99,5 +101,5 @@
             public void mouseClicked(MouseEvent e) {
                 if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2 && noteData != null && noteData.getSelectedNote() != null) {
-                    Main.map.mapView.zoomTo(noteData.getSelectedNote().getLatLon());
+                    MainApplication.getMap().mapView.zoomTo(noteData.getSelectedNote().getLatLon());
                 }
             }
@@ -161,6 +163,7 @@
             noteData = null;
             model.clearData();
-            if (Main.map.mapMode instanceof AddNoteAction) {
-                Main.map.selectMapMode(Main.map.mapModeSelect);
+            MapFrame map = MainApplication.getMap();
+            if (map.mapMode instanceof AddNoteAction) {
+                map.selectMapMode(map.mapModeSelect);
             }
         }
@@ -297,5 +300,5 @@
             Note note = displayList.getSelectedValue();
             if (note == null) {
-                JOptionPane.showMessageDialog(Main.map,
+                JOptionPane.showMessageDialog(MainApplication.getMap(),
                         "You must select a note first",
                         "No note selected",
@@ -355,5 +358,5 @@
                 Main.getLayerManager().addLayer(new NoteLayer());
             }
-            Main.map.selectMapMode(new AddNoteAction(noteData));
+            MainApplication.getMap().selectMapMode(new AddNoteAction(noteData));
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java	(revision 12630)
@@ -57,4 +57,5 @@
 import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent;
 import org.openstreetmap.josm.gui.DefaultNameFormatter;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.NavigatableComponent;
@@ -209,6 +210,6 @@
 
         //update highlights
-        if (highlightEnabled && focused == displaylist && Main.isDisplayingMapView() && highlightHelper.highlightOnly(sel)) {
-            Main.map.mapView.repaint();
+        if (highlightEnabled && focused == displaylist && MainApplication.isDisplayingMapView() && highlightHelper.highlightOnly(sel)) {
+            MainApplication.getMap().mapView.repaint();
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java	(revision 12630)
@@ -67,4 +67,6 @@
 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
 import org.openstreetmap.josm.gui.DefaultNameFormatter;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.OsmPrimitivRenderer;
 import org.openstreetmap.josm.gui.PopupMenuHandler;
@@ -212,6 +214,6 @@
                     actEditRelationSelection.actionPerformed(null);
                 }
-            } else if (highlightEnabled && Main.isDisplayingMapView() && helper.highlightOnly(model.getElementAt(idx))) {
-                Main.map.mapView.repaint();
+            } else if (highlightEnabled && MainApplication.isDisplayingMapView() && helper.highlightOnly(model.getElementAt(idx))) {
+                MainApplication.getMap().mapView.repaint();
             }
         }
@@ -442,5 +444,5 @@
                 return;
             box.enlargeBoundingBox();
-            Main.map.mapView.zoomTo(box);
+            MainApplication.getMap().mapView.zoomTo(box);
         }
 
@@ -615,4 +617,5 @@
                     if (selection != null) {
                         remember(selection);
+                        MapFrame map = MainApplication.getMap();
                         if (selection.size() == 2) {
                             Iterator<? extends OsmPrimitive> it = selection.iterator();
@@ -624,10 +627,10 @@
                                 LatLon c2 = ((Node) n2).getCoor();
                                 if (c1 != null && c2 != null) {
-                                    Main.map.statusLine.setDist(c1.greatCircleDistance(c2));
+                                    map.statusLine.setDist(c1.greatCircleDistance(c2));
                                     return;
                                 }
                             }
                         }
-                        Main.map.statusLine.setDist(
+                        map.statusLine.setDist(
                                 new SubclassFilteredCollection<OsmPrimitive, Way>(selection, Way.class::isInstance));
                     }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java	(revision 12630)
@@ -43,4 +43,6 @@
 import org.openstreetmap.josm.data.validation.TestError;
 import org.openstreetmap.josm.data.validation.ValidatorVisitor;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.PleaseWaitRunnable;
 import org.openstreetmap.josm.gui.PopupMenuHandler;
@@ -315,5 +317,5 @@
             tree.resetErrors();
             OsmValidator.saveIgnoredErrors();
-            Main.map.repaint();
+            MainApplication.getMap().repaint();
         }
     }
@@ -524,6 +526,7 @@
             fixButton.setEnabled(hasFixes);
             popupMenuHandler.setPrimitives(sel);
-            if (Main.map != null) {
-                Main.map.repaint();
+            MapFrame map = MainApplication.getMap();
+            if (map != null) {
+                map.repaint();
             }
         }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/BasicChangesetQueryPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/BasicChangesetQueryPanel.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/BasicChangesetQueryPanel.java	(revision 12630)
@@ -22,4 +22,6 @@
 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.widgets.HtmlPanel;
 import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
@@ -165,8 +167,7 @@
         }
 
-        // query for changesets in the current map view only if there *is* a current
-        // map view
+        // query for changesets in the current map view only if there *is* a current map view
         lbl = lblQueries.get(BasicQuery.CHANGESETS_IN_MAP_VIEW);
-        if (!Main.isDisplayingMapView()) {
+        if (!MainApplication.isDisplayingMapView()) {
             rbQueries.get(BasicQuery.CHANGESETS_IN_MAP_VIEW).setEnabled(false);
             lbl.setText(tr("<html>Download changesets in the current map view.<br><em>Disabled. " +
@@ -241,5 +242,6 @@
             break;
         case CHANGESETS_IN_MAP_VIEW:
-            Bounds b = Main.map.mapView.getLatLonBounds(Main.map.mapView.getBounds());
+            MapView mapView = MainApplication.getMap().mapView;
+            Bounds b = mapView.getLatLonBounds(mapView.getBounds());
             query = query.inBbox(b);
             break;
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java	(revision 12630)
@@ -83,4 +83,5 @@
 import org.openstreetmap.josm.gui.DefaultNameFormatter;
 import org.openstreetmap.josm.gui.ExtendedDialog;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.PopupMenuHandler;
 import org.openstreetmap.josm.gui.SideButton;
@@ -385,8 +386,8 @@
             public void mouseClicked(MouseEvent e) {
                 //update highlights
-                if (Main.isDisplayingMapView()) {
+                if (MainApplication.isDisplayingMapView()) {
                     int row = membershipTable.rowAtPoint(e.getPoint());
                     if (row >= 0 && highlightHelper.highlightOnly((Relation) membershipTable.getValueAt(row, 0))) {
-                        Main.map.mapView.repaint();
+                        MainApplication.getMap().mapView.repaint();
                     }
                 }
@@ -484,5 +485,5 @@
     private void editMembership(int row) {
         Relation relation = (Relation) membershipData.getValueAt(row, 0);
-        Main.map.relationListDialog.selectRelation(relation);
+        MainApplication.getMap().relationListDialog.selectRelation(relation);
         RelationEditor.getEditor(
                 Main.getLayerManager().getEditLayer(),
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ChildRelationBrowser.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ChildRelationBrowser.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ChildRelationBrowser.java	(revision 12630)
@@ -36,4 +36,5 @@
 import org.openstreetmap.josm.gui.DefaultNameFormatter;
 import org.openstreetmap.josm.gui.ExceptionDialogUtil;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.PleaseWaitRunnable;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
@@ -420,5 +421,5 @@
                     refreshView(r);
                 }
-                SwingUtilities.invokeLater(Main.map::repaint);
+                SwingUtilities.invokeLater(MainApplication.getMap()::repaint);
             } catch (OsmTransferException e) {
                 if (canceled) {
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/relation/DownloadRelationMemberTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/relation/DownloadRelationMemberTask.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/relation/DownloadRelationMemberTask.java	(revision 12630)
@@ -13,5 +13,4 @@
 import javax.swing.SwingUtilities;
 
-import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -19,4 +18,5 @@
 import org.openstreetmap.josm.gui.DefaultNameFormatter;
 import org.openstreetmap.josm.gui.ExceptionDialogUtil;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.PleaseWaitRunnable;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
@@ -83,5 +83,5 @@
     @Override
     protected void finish() {
-        Main.map.repaint();
+        MainApplication.getMap().repaint();
         if (canceled)
             return;
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/relation/DownloadRelationTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/relation/DownloadRelationTask.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/relation/DownloadRelationTask.java	(revision 12630)
@@ -10,5 +10,4 @@
 import javax.swing.SwingUtilities;
 
-import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.DataSetMerger;
@@ -16,4 +15,5 @@
 import org.openstreetmap.josm.gui.DefaultNameFormatter;
 import org.openstreetmap.josm.gui.ExceptionDialogUtil;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.PleaseWaitRunnable;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
@@ -102,5 +102,5 @@
                 layer.mergeFrom(allDownloads);
                 layer.onPostDownloadFromServer();
-                Main.map.repaint();
+                MainApplication.getMap().repaint();
             });
         } catch (OsmTransferException | InvocationTargetException | InterruptedException e) {
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java	(revision 12630)
@@ -28,4 +28,5 @@
 import org.openstreetmap.josm.data.osm.RelationMember;
 import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionType;
 import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionType.Direction;
@@ -108,5 +109,5 @@
 
     private transient ListSelectionListener highlighterListener = lse -> {
-        if (Main.isDisplayingMapView()) {
+        if (MainApplication.isDisplayingMapView()) {
             Collection<RelationMember> sel = getMemberTableModel().getSelectedMembers();
             final Set<OsmPrimitive> toHighlight = new HashSet<>();
@@ -117,6 +118,6 @@
             }
             SwingUtilities.invokeLater(() -> {
-                if (Main.isDisplayingMapView() && highlightHelper.highlightOnly(toHighlight)) {
-                    Main.map.mapView.repaint();
+                if (MainApplication.isDisplayingMapView() && highlightHelper.highlightOnly(toHighlight)) {
+                    MainApplication.getMap().mapView.repaint();
                 }
             });
@@ -128,7 +129,7 @@
         if (!highlightEnabled) return;
         getMemberTableModel().getSelectionModel().addListSelectionListener(highlighterListener);
-        if (Main.isDisplayingMapView()) {
+        if (MainApplication.isDisplayingMapView()) {
             HighlightHelper.clearAllHighlighted();
-            Main.map.mapView.repaint();
+            MainApplication.getMap().mapView.repaint();
         }
     }
@@ -153,7 +154,7 @@
         getMemberTableModel().getSelectionModel().removeListSelectionListener(highlighterListener);
         highlighterListener = null;
-        if (Main.isDisplayingMapView()) {
+        if (MainApplication.isDisplayingMapView()) {
             HighlightHelper.clearAllHighlighted();
-            Main.map.mapView.repaint();
+            MainApplication.getMap().mapView.repaint();
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/SavingAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/SavingAction.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/SavingAction.java	(revision 12630)
@@ -21,4 +21,5 @@
 import org.openstreetmap.josm.gui.HelpAwareOptionPane;
 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.dialogs.relation.IRelationEditor;
 import org.openstreetmap.josm.gui.dialogs.relation.MemberTable;
@@ -82,5 +83,5 @@
         }
         // Relation list gets update in EDT so selecting my be postponed to following EDT run
-        SwingUtilities.invokeLater(() -> Main.map.relationListDialog.selectRelation(newRelation));
+        SwingUtilities.invokeLater(() -> MainApplication.getMap().relationListDialog.selectRelation(newRelation));
     }
 
@@ -140,5 +141,5 @@
         );
         if (ret == 0) {
-            Main.map.conflictDialog.unfurlDialog();
+            MainApplication.getMap().conflictDialog.unfurlDialog();
         }
         return ret == 0;
Index: trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java	(revision 12630)
@@ -39,4 +39,5 @@
 import org.openstreetmap.josm.data.preferences.BooleanProperty;
 import org.openstreetmap.josm.data.preferences.IntegerProperty;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
@@ -408,6 +409,6 @@
         tpDownloadAreaSelectors.setSelectedIndex(idx);
 
-        if (Main.isDisplayingMapView()) {
-            MapView mv = Main.map.mapView;
+        if (MainApplication.isDisplayingMapView()) {
+            MapView mv = MainApplication.getMap().mapView;
             currentBounds = new Bounds(
                     mv.getLatLon(0, mv.getHeight()),
Index: trunk/src/org/openstreetmap/josm/gui/io/AbstractPrimitiveTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/AbstractPrimitiveTask.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/io/AbstractPrimitiveTask.java	(revision 12630)
@@ -7,5 +7,4 @@
 import java.util.Set;
 
-import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.AutoScaleAction;
 import org.openstreetmap.josm.data.osm.DataSet;
@@ -16,4 +15,5 @@
 import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.gui.ExceptionDialogUtil;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.PleaseWaitRunnable;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
@@ -186,5 +186,5 @@
         GuiHelper.runInEDTAndWait(() -> {
             layer.mergeFrom(ds);
-            if (zoom && Main.map != null)
+            if (zoom && MainApplication.getMap() != null)
                 AutoScaleAction.zoomTo(ds.allPrimitives());
             layer.onPostDownloadFromServer();
Index: trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java	(revision 12630)
@@ -28,4 +28,5 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.osm.Changeset;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.widgets.HistoryComboBox;
 import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
@@ -84,5 +85,5 @@
         sourceLabel.addHyperlinkListener(e -> {
             if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
-                final String source = Main.map.mapView.getLayerInformationForSourceTag();
+                final String source = MainApplication.getMap().mapView.getLayerInformationForSourceTag();
                 hcbUploadSource.setText(Utils.shortenString(source, Changeset.MAX_CHANGESET_TAG_LENGTH));
                 // Fix #9965
Index: trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java	(revision 12630)
@@ -89,4 +89,5 @@
 import org.openstreetmap.josm.data.projection.Projections;
 import org.openstreetmap.josm.gui.ExtendedDialog;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener;
@@ -261,5 +262,5 @@
 
     protected void initTileSource(T tileSource) {
-        coordinateConverter = new TileCoordinateConverter(Main.map.mapView, tileSource, getDisplaySettings());
+        coordinateConverter = new TileCoordinateConverter(MainApplication.getMap().mapView, tileSource, getDisplaySettings());
         attribution.initialize(tileSource);
 
@@ -852,5 +853,5 @@
 
     private TileSet getVisibleTileSet() {
-        ProjectionBounds bounds = Main.map.mapView.getState().getViewArea().getProjectionBounds();
+        ProjectionBounds bounds = MainApplication.getMap().mapView.getState().getViewArea().getProjectionBounds();
         return getTileSet(bounds, currentZoomLevel);
     }
@@ -987,5 +988,6 @@
                 drawImageInside(g, img, anchorImage, anchorScreen, null);
             }
-            if (tile instanceof ReprojectionTile && ((ReprojectionTile) tile).needsUpdate(Main.map.mapView.getScale())) {
+            MapView mapView = MainApplication.getMap().mapView;
+            if (tile instanceof ReprojectionTile && ((ReprojectionTile) tile).needsUpdate(mapView.getScale())) {
                 // This means we have a reprojected tile in memory cache, but not at
                 // current scale. Generally, the positioning of the tile will still
Index: trunk/src/org/openstreetmap/josm/gui/layer/AlignImageryPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/AlignImageryPanel.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/layer/AlignImageryPanel.java	(revision 12630)
@@ -15,7 +15,8 @@
 import javax.swing.border.EtchedBorder;
 
-import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.imagery.ImageryInfo;
 import org.openstreetmap.josm.data.preferences.BooleanProperty;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.util.GuiHelper;
 import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
@@ -54,6 +55,6 @@
         closeButton.setToolTipText(tr("Hide this message and never show it again"));
         closeButton.addActionListener(e -> {
-            if (Main.isDisplayingMapView()) {
-                Main.map.removeTopPanel(AlignImageryPanel.class);
+            if (MainApplication.isDisplayingMapView()) {
+                MainApplication.getMap().removeTopPanel(AlignImageryPanel.class);
                 if (doNotShowAgain.isSelected()) {
                     showAgain.put(Boolean.FALSE);
@@ -83,8 +84,9 @@
     public static void addNagPanelIfNeeded(ImageryInfo infoToAdd) {
         BooleanProperty showAgain = new BooleanProperty("message.imagery.nagPanel." + infoToAdd.getUrl(), true);
-        if (Main.isDisplayingMapView() && showAgain.get() && !infoToAdd.isGeoreferenceValid()
-                && Main.map.getTopPanel(AlignImageryPanel.class) == null) {
+        MapFrame map = MainApplication.getMap();
+        if (MainApplication.isDisplayingMapView() && showAgain.get() && !infoToAdd.isGeoreferenceValid()
+                && map.getTopPanel(AlignImageryPanel.class) == null) {
             double w = GuiHelper.getScreenSize().getWidth();
-            Main.map.addTopPanel(new AlignImageryPanel(w > 1300, showAgain, infoToAdd));
+            map.addTopPanel(new AlignImageryPanel(w > 1300, showAgain, infoToAdd));
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java	(revision 12630)
@@ -35,4 +35,6 @@
 import org.openstreetmap.josm.data.imagery.OffsetBookmark;
 import org.openstreetmap.josm.data.preferences.IntegerProperty;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.MenuScroller;
 import org.openstreetmap.josm.gui.layer.imagery.ImageryFilterSettings;
@@ -81,8 +83,9 @@
 
     public double getPPD() {
-        if (!Main.isDisplayingMapView())
+        if (!MainApplication.isDisplayingMapView())
             return Main.getProjection().getDefaultZoomInPPD();
-        ProjectionBounds bounds = Main.map.mapView.getProjectionBounds();
-        return Main.map.mapView.getWidth() / (bounds.maxEast - bounds.minEast);
+        MapView mapView = MainApplication.getMap().mapView;
+        ProjectionBounds bounds = mapView.getProjectionBounds();
+        return mapView.getWidth() / (bounds.maxEast - bounds.minEast);
     }
 
@@ -206,5 +209,5 @@
             setOffset(b);
             Main.main.menu.imageryMenu.refreshOffsetMenu();
-            Main.map.repaint();
+            MainApplication.getMap().repaint();
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/layer/LayerManager.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/LayerManager.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/layer/LayerManager.java	(revision 12630)
@@ -12,5 +12,5 @@
 import java.util.function.Consumer;
 
-import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.util.GuiHelper;
 import org.openstreetmap.josm.tools.JosmRuntimeException;
@@ -232,5 +232,5 @@
         insertLayerAt(layer, position);
         fireLayerAdded(layer, initialZoom);
-        if (Main.map != null) {
+        if (MainApplication.getMap() != null) {
             layer.hookUpMapView(); // needs to be after fireLayerAdded
         }
Index: trunk/src/org/openstreetmap/josm/gui/layer/NoteLayer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/NoteLayer.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/layer/NoteLayer.java	(revision 12630)
@@ -32,4 +32,5 @@
 import org.openstreetmap.josm.data.osm.NoteData.NoteDataUpdateListener;
 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.datatransfer.ClipboardUtils;
@@ -73,10 +74,10 @@
     @Override
     public void hookUpMapView() {
-        Main.map.mapView.addMouseListener(this);
+        MainApplication.getMap().mapView.addMouseListener(this);
     }
 
     @Override
     public synchronized void destroy() {
-        Main.map.mapView.removeMouseListener(this);
+        MainApplication.getMap().mapView.removeMouseListener(this);
         noteData.removeNoteDataUpdateListener(this);
         super.destroy();
@@ -134,5 +135,5 @@
             int width = icon.getIconWidth();
             int height = icon.getIconHeight();
-            g.drawImage(icon.getImage(), p.x - (width / 2), p.y - height, Main.map.mapView);
+            g.drawImage(icon.getImage(), p.x - (width / 2), p.y - height, MainApplication.getMap().mapView);
         }
         if (noteData.getSelectedNote() != null) {
@@ -260,5 +261,5 @@
         Note closestNote = null;
         for (Note note : noteData.getNotes()) {
-            Point notePoint = Main.map.mapView.getPoint(note.getLatLon());
+            Point notePoint = MainApplication.getMap().mapView.getPoint(note.getLatLon());
             //move the note point to the center of the icon where users are most likely to click when selecting
             notePoint.setLocation(notePoint.getX(), notePoint.getY() - iconHeight / 2);
Index: trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java	(revision 12630)
@@ -87,4 +87,6 @@
 import org.openstreetmap.josm.data.validation.TestError;
 import org.openstreetmap.josm.gui.ExtendedDialog;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.MapViewState.MapViewPoint;
@@ -176,6 +178,7 @@
     public void setRecentRelation(Relation relation) {
         recentRelations.put(relation, null);
-        if (Main.map != null && Main.map.relationListDialog != null) {
-            Main.map.relationListDialog.enableRecentRelations();
+        MapFrame map = MainApplication.getMap();
+        if (map != null && map.relationListDialog != null) {
+            map.relationListDialog.enableRecentRelations();
         }
     }
@@ -188,6 +191,7 @@
     public void removeRecentRelation(Relation relation) {
         recentRelations.remove(relation);
-        if (Main.map != null && Main.map.relationListDialog != null) {
-            Main.map.relationListDialog.enableRecentRelations();
+        MapFrame map = MainApplication.getMap();
+        if (map != null && map.relationListDialog != null) {
+            map.relationListDialog.enableRecentRelations();
         }
     }
@@ -478,5 +482,5 @@
         Rendering painter = MapRendererFactory.getInstance().createActiveRenderer(g, mv, inactive);
         painter.render(data, virtual, box);
-        Main.map.conflictDialog.paintConflicts(g, mv);
+        MainApplication.getMap().conflictDialog.paintConflicts(g, mv);
     }
 
@@ -571,6 +575,7 @@
         invalidate();
         // warn about new conflicts
-        if (numNewConflicts > 0 && Main.map != null && Main.map.conflictDialog != null) {
-            Main.map.conflictDialog.warnNumNewConflicts(numNewConflicts);
+        MapFrame map = MainApplication.getMap();
+        if (numNewConflicts > 0 && map != null && map.conflictDialog != null) {
+            map.conflictDialog.warnNumNewConflicts(numNewConflicts);
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/layer/ValidatorLayer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/ValidatorLayer.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/layer/ValidatorLayer.java	(revision 12630)
@@ -22,4 +22,5 @@
 import org.openstreetmap.josm.data.validation.Severity;
 import org.openstreetmap.josm.data.validation.TestError;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
@@ -49,5 +50,5 @@
         super(tr("Validation errors"));
         Main.getLayerManager().addLayerChangeListener(this);
-        Main.map.validatorDialog.tree.addInvalidationListener(invalidator);
+        MainApplication.getMap().validatorDialog.tree.addInvalidationListener(invalidator);
     }
 
@@ -68,5 +69,5 @@
     @Override
     public void paint(final Graphics2D g, final MapView mv, Bounds bounds) {
-        DefaultMutableTreeNode root = Main.map.validatorDialog.tree.getRoot();
+        DefaultMutableTreeNode root = MainApplication.getMap().validatorDialog.tree.getRoot();
         if (root == null || root.getChildCount() == 0)
             return;
@@ -94,5 +95,5 @@
     public String getToolTipText() {
         MultiMap<Severity, TestError> errorTree = new MultiMap<>();
-        List<TestError> errors = Main.map.validatorDialog.tree.getErrors();
+        List<TestError> errors = MainApplication.getMap().validatorDialog.tree.getErrors();
         for (TestError e : errors) {
             errorTree.put(e.getSeverity(), e);
@@ -173,5 +174,5 @@
     @Override
     public synchronized void destroy() {
-        Main.map.validatorDialog.tree.removeInvalidationListener(invalidator);
+        MainApplication.getMap().validatorDialog.tree.removeInvalidationListener(invalidator);
         Main.getLayerManager().removeLayerChangeListener(this);
         super.destroy();
Index: trunk/src/org/openstreetmap/josm/gui/layer/WMTSLayer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/WMTSLayer.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/layer/WMTSLayer.java	(revision 12630)
@@ -14,4 +14,5 @@
 import org.openstreetmap.josm.data.imagery.WMTSTileSource;
 import org.openstreetmap.josm.data.projection.Projection;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings;
 import org.openstreetmap.josm.tools.Logging;
@@ -71,5 +72,5 @@
     @Override
     public int getBestZoom() {
-        if (!Main.isDisplayingMapView())
+        if (!MainApplication.isDisplayingMapView())
             return 0;
         ScaleList scaleList = getNativeScales();
@@ -77,5 +78,5 @@
             return getMaxZoomLvl();
         }
-        double displayScale = Main.map.mapView.getScale();
+        double displayScale = MainApplication.getMap().mapView.getScale();
         if (coordinateConverter.requiresReprojection()) {
             displayScale *= Main.getProjection().getMetersPerUnit();
Index: trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java	(revision 12630)
@@ -71,4 +71,5 @@
 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
 import org.openstreetmap.josm.gui.ExtendedDialog;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.layer.GpxLayer;
 import org.openstreetmap.josm.gui.layer.Layer;
@@ -194,5 +195,5 @@
                     BoundingXYVisitor bbox = new BoundingXYVisitor();
                     yLayer.visitBoundingBox(bbox);
-                    Main.map.mapView.zoomTo(bbox);
+                    MainApplication.getMap().mapView.zoomTo(bbox);
                 }
 
Index: trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java	(revision 12630)
@@ -47,4 +47,5 @@
 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
 import org.openstreetmap.josm.gui.ExtendedDialog;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.MapFrame.MapModeChangeListener;
@@ -458,5 +459,5 @@
 
     private static Dimension scaledDimension(Image thumb) {
-        final double d = Main.map.mapView.getDist100Pixel();
+        final double d = MainApplication.getMap().mapView.getDist100Pixel();
         final double size = 10 /*meter*/;     /* size of the photo on the map */
         double s = size * 100 /*px*/ / d;
@@ -778,5 +779,5 @@
             ImageEntry img = data.get(idx);
             if (img.getPos() != null) {
-                Point imgCenter = Main.map.mapView.getPoint(img.getPos());
+                Point imgCenter = MainApplication.getMap().mapView.getPoint(img.getPos());
                 Rectangle imgRect;
                 if (useThumbs && img.hasThumbnail()) {
@@ -932,5 +933,6 @@
         mouseAdapter = new MouseAdapter() {
             private boolean isMapModeOk() {
-                return Main.map.mapMode == null || isSupportedMapMode(Main.map.mapMode);
+                MapMode mapMode = MainApplication.getMap().mapMode;
+                return mapMode == null || isSupportedMapMode(mapMode);
             }
 
@@ -977,20 +979,21 @@
 
         mapModeListener = (oldMapMode, newMapMode) -> {
+            MapView mapView = MainApplication.getMap().mapView;
             if (newMapMode == null || isSupportedMapMode(newMapMode)) {
-                Main.map.mapView.addMouseListener(mouseAdapter);
-                Main.map.mapView.addMouseMotionListener(mouseMotionAdapter);
+                mapView.addMouseListener(mouseAdapter);
+                mapView.addMouseMotionListener(mouseMotionAdapter);
             } else {
-                Main.map.mapView.removeMouseListener(mouseAdapter);
-                Main.map.mapView.removeMouseMotionListener(mouseMotionAdapter);
+                mapView.removeMouseListener(mouseAdapter);
+                mapView.removeMouseMotionListener(mouseMotionAdapter);
             }
         };
 
         MapFrame.addMapModeChangeListener(mapModeListener);
-        mapModeListener.mapModeChange(null, Main.map.mapMode);
+        mapModeListener.mapModeChange(null, MainApplication.getMap().mapMode);
 
         Main.getLayerManager().addActiveLayerChangeListener(e -> {
             if (Main.getLayerManager().getActiveLayer() == this) {
                 // only in select mode it is possible to click the images
-                Main.map.selectSelectTool(false);
+                MainApplication.getMap().selectSelectTool(false);
             }
         });
@@ -1006,6 +1009,7 @@
                 if (e.getRemovedLayer() == GeoImageLayer.this) {
                     stopLoadThumbs();
-                    Main.map.mapView.removeMouseListener(mouseAdapter);
-                    Main.map.mapView.removeMouseMotionListener(mouseMotionAdapter);
+                    MapView mapView = MainApplication.getMap().mapView;
+                    mapView.removeMouseListener(mouseAdapter);
+                    mapView.removeMouseMotionListener(mouseMotionAdapter);
                     MapFrame.removeMapModeChangeListener(mapModeListener);
                     currentPhoto = -1;
@@ -1025,7 +1029,8 @@
         });
 
-        if (Main.map.getToggleDialog(ImageViewerDialog.class) == null) {
+        MapFrame map = MainApplication.getMap();
+        if (map.getToggleDialog(ImageViewerDialog.class) == null) {
             ImageViewerDialog.newInstance();
-            Main.map.addToggleDialog(ImageViewerDialog.getInstance());
+            map.addToggleDialog(ImageViewerDialog.getInstance());
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java	(revision 12630)
@@ -23,4 +23,5 @@
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.dialogs.DialogsPanel.Action;
 import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
@@ -236,5 +237,5 @@
                 centerView = button.isEnabled() && button.isSelected();
                 if (centerView && currentEntry != null && currentEntry.getPos() != null) {
-                    Main.map.mapView.zoomTo(currentEntry.getPos());
+                    MainApplication.getMap().mapView.zoomTo(currentEntry.getPos());
                 }
             } else if (COMMAND_ZOOM.equals(action)) {
@@ -309,6 +310,6 @@
             imageChanged = currentEntry != entry;
 
-            if (centerView && entry != null && Main.isDisplayingMapView() && entry.getPos() != null) {
-                Main.map.mapView.zoomTo(entry.getPos());
+            if (centerView && entry != null && MainApplication.isDisplayingMapView() && entry.getPos() != null) {
+                MainApplication.getMap().mapView.zoomTo(entry.getPos());
             }
 
Index: trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ThumbsLoader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ThumbsLoader.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ThumbsLoader.java	(revision 12630)
@@ -21,4 +21,5 @@
 import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry;
 import org.openstreetmap.josm.data.cache.JCSCacheManager;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.tools.ExifReader;
 import org.openstreetmap.josm.tools.Logging;
@@ -79,5 +80,5 @@
     public void run() {
         Logging.debug("Load Thumbnails");
-        tracker = new MediaTracker(Main.map.mapView);
+        tracker = new MediaTracker(MainApplication.getMap().mapView);
         for (ImageEntry entry : data) {
             if (stop) return;
@@ -87,5 +88,5 @@
                 entry.setThumbnail(loadThumb(entry));
 
-                if (layer != null && Main.isDisplayingMapView()) {
+                if (layer != null && MainApplication.isDisplayingMapView()) {
                     layer.updateBufferAndRepaint();
                 }
Index: trunk/src/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityAction.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityAction.java	(revision 12630)
@@ -36,4 +36,5 @@
 import org.openstreetmap.josm.data.gpx.GpxTrack;
 import org.openstreetmap.josm.gui.ExtendedDialog;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.layer.GpxLayer;
 import org.openstreetmap.josm.tools.GBC;
@@ -279,5 +280,5 @@
             if (v != 1 && v != 2) {
                 layer.trackVisibility = Arrays.copyOf(trackVisibilityBackup, layer.trackVisibility.length);
-                Main.map.repaint();
+                MainApplication.getMap().repaint();
                 return;
             }
Index: trunk/src/org/openstreetmap/josm/gui/layer/gpx/CustomizeDrawingAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/gpx/CustomizeDrawingAction.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/layer/gpx/CustomizeDrawingAction.java	(revision 12630)
@@ -19,4 +19,5 @@
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.layer.GpxLayer;
 import org.openstreetmap.josm.gui.layer.Layer;
@@ -111,5 +112,5 @@
             panel.savePreferences(layer.getName(), f);
         }
-        Main.map.repaint();
+        MainApplication.getMap().repaint();
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java	(revision 12630)
@@ -26,4 +26,5 @@
 import org.openstreetmap.josm.data.gpx.WayPoint;
 import org.openstreetmap.josm.gui.HelpAwareOptionPane;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.layer.GpxLayer;
 import org.openstreetmap.josm.gui.layer.markerlayer.AudioMarker;
@@ -115,5 +116,5 @@
             }
             Main.getLayerManager().addLayer(ml);
-            Main.map.repaint();
+            MainApplication.getMap().repaint();
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/layer/imagery/ReprojectionTile.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/imagery/ReprojectionTile.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/layer/imagery/ReprojectionTile.java	(revision 12630)
@@ -13,4 +13,5 @@
 import org.openstreetmap.josm.data.projection.Projection;
 import org.openstreetmap.josm.data.projection.Projections;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.tools.ImageWarp;
 import org.openstreetmap.josm.tools.Utils;
@@ -101,9 +102,9 @@
      */
     protected void transform(BufferedImage imageIn) {
-        if (!Main.isDisplayingMapView()) {
+        if (!MainApplication.isDisplayingMapView()) {
             reset();
             return;
         }
-        double scaleMapView = Main.map.mapView.getScale();
+        double scaleMapView = MainApplication.getMap().mapView.getScale();
         ImageWarp.Interpolation interpolation;
         switch (Main.pref.get("imagery.warp.pixel-interpolation", "bilinear")) {
Index: trunk/src/org/openstreetmap/josm/gui/layer/imagery/ZoomToNativeLevelAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/imagery/ZoomToNativeLevelAction.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/layer/imagery/ZoomToNativeLevelAction.java	(revision 12630)
@@ -8,5 +8,5 @@
 import javax.swing.AbstractAction;
 
-import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer;
 
@@ -31,5 +31,5 @@
     public void actionPerformed(ActionEvent ae) {
         double newFactor = Math.sqrt(layer.getScaleFactor(layer.getZoomLevel()));
-        Main.map.mapView.zoomToFactor(newFactor);
+        MainApplication.getMap().mapView.zoomToFactor(newFactor);
         layer.invalidate();
     }
Index: trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/AudioMarker.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/AudioMarker.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/AudioMarker.java	(revision 12630)
@@ -7,9 +7,9 @@
 import java.util.Collections;
 
-import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.gpx.GpxConstants;
 import org.openstreetmap.josm.data.gpx.GpxLink;
 import org.openstreetmap.josm.data.gpx.WayPoint;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.io.audio.AudioPlayer;
 import org.openstreetmap.josm.io.audio.AudioUtil;
@@ -56,5 +56,5 @@
         try {
             // first enable tracing the audio along the track
-            Main.map.mapView.playHeadMarker.animate();
+            MainApplication.getMap().mapView.playHeadMarker.animate();
 
             AudioPlayer.play(audioUrl, offset + syncOffset + after);
Index: trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/ButtonMarker.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/ButtonMarker.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/ButtonMarker.java	(revision 12630)
@@ -13,4 +13,5 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.tools.template_engine.TemplateEngineDataProvider;
@@ -38,5 +39,5 @@
 
     @Override public boolean containsPoint(Point p) {
-        Point screen = Main.map.mapView.getPoint(getEastNorth());
+        Point screen = MainApplication.getMap().mapView.getPoint(getEastNorth());
         buttonRectangle.setLocation(screen.x+4, screen.y+2);
         return buttonRectangle.contains(p);
Index: trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java	(revision 12630)
@@ -39,4 +39,5 @@
 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
 import org.openstreetmap.josm.data.preferences.ColorProperty;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
@@ -351,5 +352,5 @@
             }
         }
-        Main.map.mapView.zoomTo(currentMarker.getEastNorth());
+        MainApplication.getMap().mapView.zoomTo(currentMarker.getEastNorth());
     }
 
@@ -370,5 +371,5 @@
             }
         }
-        Main.map.mapView.zoomTo(currentMarker.getEastNorth());
+        MainApplication.getMap().mapView.zoomTo(currentMarker.getEastNorth());
     }
 
@@ -413,5 +414,5 @@
 
     private static void playAdjacentMarker(Marker startMarker, boolean next) {
-        if (!Main.isDisplayingMapView())
+        if (!MainApplication.isDisplayingMapView())
             return;
         Marker m = null;
@@ -565,5 +566,5 @@
                 return;
             }
-            PlayHeadMarker playHeadMarker = Main.map.mapView.playHeadMarker;
+            PlayHeadMarker playHeadMarker = MainApplication.getMap().mapView.playHeadMarker;
             if (playHeadMarker == null)
                 return;
Index: trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java	(revision 12630)
@@ -22,4 +22,6 @@
 import org.openstreetmap.josm.data.gpx.GpxTrackSegment;
 import org.openstreetmap.josm.data.gpx.WayPoint;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.layer.GpxLayer;
@@ -63,14 +65,15 @@
         if (!enabled) return;
         dropTolerance = Main.pref.getInteger("marker.playHeadDropTolerance", 50);
-        if (Main.isDisplayingMapView()) {
-            Main.map.mapView.addMouseListener(new MouseAdapter() {
+        if (MainApplication.isDisplayingMapView()) {
+            MapFrame map = MainApplication.getMap();
+            map.mapView.addMouseListener(new MouseAdapter() {
                 @Override public void mousePressed(MouseEvent ev) {
                     if (ev.getButton() == MouseEvent.BUTTON1 && playHead.containsPoint(ev.getPoint())) {
                         /* when we get a click on the marker, we need to switch mode to avoid
                          * getting confused with other drag operations (like select) */
-                        oldMode = Main.map.mapMode;
+                        oldMode = map.mapMode;
                         oldCoor = getCoor();
                         PlayHeadDragMode playHeadDragMode = new PlayHeadDragMode(playHead);
-                        Main.map.selectMapMode(playHeadDragMode);
+                        map.selectMapMode(playHeadDragMode);
                         playHeadDragMode.mousePressed(ev);
                     }
@@ -82,5 +85,5 @@
     @Override
     public boolean containsPoint(Point p) {
-        Point screen = Main.map.mapView.getPoint(getEastNorth());
+        Point screen = MainApplication.getMap().mapView.getPoint(getEastNorth());
         Rectangle r = new Rectangle(screen.x, screen.y, symbol.getIconWidth(),
                 symbol.getIconHeight());
@@ -121,6 +124,7 @@
             setCoor(oldCoor);
         }
-        Main.map.selectMapMode(oldMode);
-        Main.map.mapView.repaint();
+        MapFrame map = MainApplication.getMap();
+        map.selectMapMode(oldMode);
+        map.mapView.repaint();
         if (timer != null) {
             timer.start();
@@ -134,5 +138,5 @@
     public void drag(EastNorth en) {
         setEastNorth(en);
-        Main.map.mapView.repaint();
+        MainApplication.getMap().mapView.repaint();
     }
 
@@ -148,6 +152,7 @@
         if (recent != null && recent.parentLayer != null && recent.parentLayer.fromLayer != null) {
             /* work out EastNorth equivalent of 50 (default) pixels tolerance */
-            Point p = Main.map.mapView.getPoint(en);
-            EastNorth enPlus25px = Main.map.mapView.getEastNorth(p.x+dropTolerance, p.y);
+            MapView mapView = MainApplication.getMap().mapView;
+            Point p = mapView.getPoint(en);
+            EastNorth enPlus25px = mapView.getEastNorth(p.x+dropTolerance, p.y);
             cw = recent.parentLayer.fromLayer.data.nearestPointOnTrack(en, enPlus25px.east() - en.east());
         }
@@ -202,5 +207,6 @@
             return;
         /* First, see if we dropped onto an existing audio marker in the layer being played */
-        Point startPoint = Main.map.mapView.getPoint(en);
+        MapView mapView = MainApplication.getMap().mapView;
+        Point startPoint = mapView.getPoint(en);
         AudioMarker ca = null;
         if (recent.parentLayer != null) {
@@ -225,6 +231,6 @@
         if (ca == null) {
             /* work out EastNorth equivalent of 50 (default) pixels tolerance */
-            Point p = Main.map.mapView.getPoint(en);
-            EastNorth enPlus25px = Main.map.mapView.getEastNorth(p.x+dropTolerance, p.y);
+            Point p = mapView.getPoint(en);
+            EastNorth enPlus25px = mapView.getEastNorth(p.x+dropTolerance, p.y);
             WayPoint cw = recent.parentLayer.fromLayer.data.nearestPointOnTrack(en, enPlus25px.east() - en.east());
             if (cw == null) {
@@ -345,9 +351,10 @@
                             (audioTime - w1.time)/(w2.time - w1.time)));
         time = audioTime;
+        MapView mapView = MainApplication.getMap().mapView;
         if (jumpToMarker) {
             jumpToMarker = false;
-            Main.map.mapView.zoomTo(w1.getEastNorth());
-        }
-        Main.map.mapView.repaint();
+            mapView.zoomTo(w1.getEastNorth());
+        }
+        mapView.repaint();
     }
 }
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintMenu.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintMenu.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintMenu.java	(revision 12630)
@@ -14,4 +14,5 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.dialogs.MapPaintDialog;
 import org.openstreetmap.josm.gui.layer.GpxLayer;
@@ -66,5 +67,5 @@
         @Override
         public void updateEnabledState() {
-            setEnabled(Main.isDisplayingMapView() && (Main.getLayerManager().getEditLayer() != null || mapHasGpxorMarkerLayer()));
+            setEnabled(MainApplication.isDisplayingMapView() && (Main.getLayerManager().getEditLayer() != null || mapHasGpxorMarkerLayer()));
         }
 
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/MapImage.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/MapImage.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/MapImage.java	(revision 12630)
@@ -12,5 +12,6 @@
 import javax.swing.ImageIcon;
 
-import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
 import org.openstreetmap.josm.gui.mappaint.StyleSource;
@@ -149,6 +150,7 @@
                         if (temporary) {
                             disabledImgCache = null;
-                            Main.map.mapView.preferenceChanged(null); // otherwise repaint is ignored, because layer hasn't changed
-                            Main.map.mapView.repaint();
+                            MapView mapView = MainApplication.getMap().mapView;
+                            mapView.preferenceChanged(null); // otherwise repaint is ignored, because layer hasn't changed
+                            mapView.repaint();
                         }
                         temporary = false;
Index: trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java	(revision 12630)
@@ -20,4 +20,5 @@
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
@@ -179,5 +180,5 @@
             MapPaintStyles.readFromPreferences();
         }
-        if (Main.isDisplayingMapView()) {
+        if (MainApplication.isDisplayingMapView()) {
             MapPaintStyles.getStyles().clearCached();
         }
Index: trunk/src/org/openstreetmap/josm/gui/progress/PleaseWaitProgressMonitor.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/progress/PleaseWaitProgressMonitor.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/progress/PleaseWaitProgressMonitor.java	(revision 12630)
@@ -12,4 +12,5 @@
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.MapStatus.BackgroundProgressMonitor;
@@ -107,5 +108,5 @@
 
         BackgroundProgressMonitor backgroundMonitor = null;
-        MapFrame map = Main.map;
+        MapFrame map = MainApplication.getMap();
         if (map != null) {
             backgroundMonitor = map.statusLine.progressMonitor;
@@ -314,5 +315,5 @@
         }
         BackgroundProgressMonitor backgroundMonitor = null;
-        MapFrame map = Main.map;
+        MapFrame map = MainApplication.getMap();
         if (map != null) {
             backgroundMonitor = map.statusLine.progressMonitor;
@@ -339,5 +340,5 @@
                 dialog = null;
                 Main.currentProgressMonitor = null;
-                MapFrame map = Main.map;
+                MapFrame map = MainApplication.getMap();
                 if (map != null) {
                     map.statusLine.progressMonitor.setVisible(false);
@@ -354,5 +355,5 @@
         doInEDT(() -> {
             if (dialog != null) {
-                dialog.setInBackgroundPossible(taskId != null && Main.isDisplayingMapView());
+                dialog.setInBackgroundPossible(taskId != null && MainApplication.isDisplayingMapView());
                 reset();
                 getDialog();
@@ -366,5 +367,5 @@
         doInEDT(() -> {
             if (dialog != null) {
-                dialog.setInBackgroundPossible(taskId != null && Main.isDisplayingMapView());
+                dialog.setInBackgroundPossible(taskId != null && MainApplication.isDisplayingMapView());
             }
         });
Index: trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingComboBox.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingComboBox.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingComboBox.java	(revision 12630)
@@ -24,4 +24,6 @@
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
 import org.openstreetmap.josm.gui.widgets.JosmComboBox;
@@ -51,6 +53,7 @@
         @Override
         public void focusLost(FocusEvent e) {
-            if (Main.map != null) {
-                Main.map.keyDetector.setEnabled(true);
+            MapFrame map = MainApplication.getMap();
+            if (map != null) {
+                map.keyDetector.setEnabled(true);
             }
         }
@@ -58,6 +61,7 @@
         @Override
         public void focusGained(FocusEvent e) {
-            if (Main.map != null) {
-                Main.map.keyDetector.setEnabled(false);
+            MapFrame map = MainApplication.getMap();
+            if (map != null) {
+                map.keyDetector.setEnabled(false);
             }
             // save unix system selection (middle mouse paste)
Index: trunk/src/org/openstreetmap/josm/gui/widgets/JosmPasswordField.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/widgets/JosmPasswordField.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/widgets/JosmPasswordField.java	(revision 12630)
@@ -13,5 +13,6 @@
 import javax.swing.text.JTextComponent;
 
-import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.tools.Logging;
 
@@ -99,6 +100,7 @@
     @Override
     public void focusGained(FocusEvent e) {
-        if (Main.map != null) {
-            Main.map.keyDetector.setEnabled(false);
+        MapFrame map = MainApplication.getMap();
+        if (map != null) {
+            map.keyDetector.setEnabled(false);
         }
     }
@@ -106,6 +108,7 @@
     @Override
     public void focusLost(FocusEvent e) {
-        if (Main.map != null) {
-            Main.map.keyDetector.setEnabled(true);
+        MapFrame map = MainApplication.getMap();
+        if (map != null) {
+            map.keyDetector.setEnabled(true);
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/widgets/JosmTextArea.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/widgets/JosmTextArea.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/widgets/JosmTextArea.java	(revision 12630)
@@ -9,5 +9,6 @@
 import javax.swing.text.Document;
 
-import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.MapFrame;
 
 /**
@@ -105,6 +106,7 @@
     @Override
     public void focusGained(FocusEvent e) {
-        if (Main.map != null) {
-            Main.map.keyDetector.setEnabled(false);
+        MapFrame map = MainApplication.getMap();
+        if (map != null) {
+            map.keyDetector.setEnabled(false);
         }
     }
@@ -112,6 +114,7 @@
     @Override
     public void focusLost(FocusEvent e) {
-        if (Main.map != null) {
-            Main.map.keyDetector.setEnabled(true);
+        MapFrame map = MainApplication.getMap();
+        if (map != null) {
+            map.keyDetector.setEnabled(true);
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/widgets/JosmTextField.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/widgets/JosmTextField.java	(revision 12629)
+++ trunk/src/org/openstreetmap/josm/gui/widgets/JosmTextField.java	(revision 12630)
@@ -14,5 +14,6 @@
 import javax.swing.text.Document;
 
-import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.MapFrame;
 
 /**
@@ -168,6 +169,7 @@
     @Override
     public void focusGained(FocusEvent e) {
-        if (Main.map != null) {
-            Main.map.keyDetector.setEnabled(false);
+        MapFrame map = MainApplication.getMap();
+        if (map != null) {
+            map.keyDetector.setEnabled(false);
         }
         repaint();
@@ -176,6 +178,7 @@
     @Override
     public void focusLost(FocusEvent e) {
-        if (Main.map != null) {
-            Main.map.keyDetector.setEnabled(true);
+        MapFrame map = MainApplication.getMap();
+        if (map != null) {
+            map.keyDetector.setEnabled(true);
         }
         repaint();
