Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/ChosenRelation.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/ChosenRelation.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/ChosenRelation.java	(revision 32398)
@@ -69,7 +69,7 @@
 
     public boolean isSame(Object r) {
-        if (r == null )
+        if (r == null)
             return chosenRelation == null;
-        else if (!(r instanceof Relation) )
+        else if (!(r instanceof Relation))
             return false;
         else
@@ -89,12 +89,13 @@
 
     public static boolean isMultipolygon(Relation r) {
-        if (r == null )
+        if (r == null)
             return false;
         String type = r.get("type");
-        if (type == null )
+        if (type == null)
             return false;
-        for (String t : MULTIPOLYGON_TYPES )
-            if (t.equals(type) )
+        for (String t : MULTIPOLYGON_TYPES) {
+            if (t.equals(type))
                 return true;
+        }
         return false;
     }
@@ -138,7 +139,7 @@
             return;
 
-        OsmDataLayer dataLayer = mv.getEditLayer();
-        float opacity = dataLayer == null ? 0.0f : !dataLayer.isVisible() ? 0.0f : (float)dataLayer.getOpacity();
-        if (opacity < 0.01 )
+        OsmDataLayer dataLayer = mv.getLayerManager().getEditLayer();
+        float opacity = dataLayer == null ? 0.0f : !dataLayer.isVisible() ? 0.0f : (float) dataLayer.getOpacity();
+        if (opacity < 0.01)
             return;
 
@@ -153,5 +154,4 @@
         g.setComposite(oldComposite);
         g.setStroke(oldStroke);
-
     }
 
@@ -159,9 +159,9 @@
         for (OsmPrimitive element : rel.getMemberPrimitives()) {
             if (element.getType() == OsmPrimitiveType.NODE) {
-                Node node = (Node)element;
+                Node node = (Node) element;
                 Point center = mv.getPoint(node);
                 g.drawOval(center.x - 4, center.y - 4, 9, 9);
             } else if (element.getType() == OsmPrimitiveType.WAY) {
-                Way way = (Way)element;
+                Way way = (Way) element;
                 if (way.getNodesCount() >= 2) {
                     GeneralPath b = new GeneralPath();
@@ -177,5 +177,5 @@
                 Color oldColor = g.getColor();
                 g.setColor(Color.magenta);
-                drawRelations(g, mv, bbox, (Relation)element);
+                drawRelations(g, mv, bbox, (Relation) element);
                 g.setColor(oldColor);
             }
@@ -186,5 +186,5 @@
     @Override
     public void relationMembersChanged(RelationMembersChangedEvent event) {
-        if (chosenRelation != null && event.getRelation().equals(chosenRelation) ) {
+        if (chosenRelation != null && event.getRelation().equals(chosenRelation)) {
             fireRelationChanged(chosenRelation);
         }
@@ -193,5 +193,5 @@
     @Override
     public void tagsChanged(TagsChangedEvent event) {
-        if (chosenRelation != null && event.getPrimitive().equals(chosenRelation) ) {
+        if (chosenRelation != null && event.getPrimitive().equals(chosenRelation)) {
             fireRelationChanged(chosenRelation);
         }
@@ -200,5 +200,5 @@
     @Override
     public void dataChanged(DataChangedEvent event) {
-        if (chosenRelation != null ) {
+        if (chosenRelation != null) {
             fireRelationChanged(chosenRelation);
         }
@@ -207,5 +207,5 @@
     @Override
     public void primitivesRemoved(PrimitivesRemovedEvent event) {
-        if (chosenRelation != null && event.getPrimitives().contains(chosenRelation) ) {
+        if (chosenRelation != null && event.getPrimitives().contains(chosenRelation)) {
             clear();
         }
@@ -214,6 +214,5 @@
     @Override
     public void wayNodesChanged(WayNodesChangedEvent event) {
-        if (chosenRelation != null )
-        {
+        if (chosenRelation != null) {
             fireRelationChanged(chosenRelation); // download incomplete primitives doesn't cause dataChanged event
         }
@@ -222,6 +221,8 @@
     @Override
     public void primitivesAdded(PrimitivesAddedEvent event) {}
+
     @Override
     public void nodeMoved(NodeMovedEvent event) {}
+
     @Override
     public void otherDatasetChange(AbstractDatasetChangedEvent event) {}
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/ChosenRelationComponent.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/ChosenRelationComponent.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/ChosenRelationComponent.java	(revision 32398)
@@ -15,12 +15,6 @@
 public class ChosenRelationComponent extends JLabel implements ChosenRelationListener {
 
-    //private ChosenRelation chRel;
-
     public ChosenRelationComponent(ChosenRelation rel) {
         super("");
-        /*        setBackground(Color.white);
-        setOpaque(true);
-        setBorder(new LineBorder(Color.black, 1, true));*/
-        //this.chRel = rel;
         rel.addChosenRelationListener(this);
     }
@@ -32,45 +26,47 @@
     }
 
-    private final static String[] TYPE_KEYS = new String[] {
+    private static final String[] TYPE_KEYS = new String[] {
             "natural", "landuse", "place", "waterway", "leisure", "amenity", "restriction", "public_transport", "route", "enforcement"
     };
 
-    private final static String[] NAMING_TAGS = new String[] {
+    private static final String[] NAMING_TAGS = new String[] {
             "name", "place_name", "ref", "destination", "note"
     };
 
     protected String prepareText(Relation rel) {
-        if (rel == null )
+        if (rel == null)
             return "";
 
         String type = rel.get("type");
-        if (type == null || type.length() == 0 ) {
+        if (type == null || type.length() == 0) {
             type = "-";
         }
 
         String tag = null;
-        for (int i = 0; i < TYPE_KEYS.length && tag == null; i++ )
+        for (int i = 0; i < TYPE_KEYS.length && tag == null; i++) {
             if (rel.hasKey(TYPE_KEYS[i])) {
                 tag = TYPE_KEYS[i];
             }
-        if (tag != null ) {
+        }
+        if (tag != null) {
             tag = tag.substring(0, 2) + "=" + rel.get(tag);
         }
 
         String name = null;
-        for (int i = 0; i < NAMING_TAGS.length && name == null; i++ )
-            if (rel.hasKey(NAMING_TAGS[i]) ) {
+        for (int i = 0; i < NAMING_TAGS.length && name == null; i++) {
+            if (rel.hasKey(NAMING_TAGS[i])) {
                 name = rel.get(NAMING_TAGS[i]);
             }
+        }
 
         StringBuilder sb = new StringBuilder();
         sb.append(type.substring(0, 1));
-        if (type.equals("boundary") && rel.hasKey("admin_level") ) {
+        if (type.equals("boundary") && rel.hasKey("admin_level")) {
             sb.append(rel.get("admin_level"));
         }
-        if (name != null ) {
+        if (name != null) {
             sb.append(" \"").append(name).append('"');
         }
-        if (tag != null ) {
+        if (tag != null) {
             sb.append("; ").append(tag);
         }
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/ExtraNameFormatHook.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/ExtraNameFormatHook.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/ExtraNameFormatHook.java	(revision 32398)
@@ -26,5 +26,5 @@
     @Override
     public String checkFormat(IWay way, String defaultName) {
-        if (way.get("place") != null && way.get("name") == null && way.get("place_name") != null )
+        if (way.get("place") != null && way.get("name") == null && way.get("place_name") != null)
             return way.get("place_name") + " " + defaultName;
         return null;
@@ -37,8 +37,8 @@
             String name = relation.get("destination");
             if (type.equals("destination_sign") && name != null) {
-                if (relation.get("distance") != null ) {
+                if (relation.get("distance") != null) {
                     name += " " + relation.get("distance");
                 }
-                if (defaultName.indexOf('"') < 0 )
+                if (defaultName.indexOf('"') < 0)
                     return '"' + name + "\" " + defaultName;
                 else
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/RelContextDialog.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/RelContextDialog.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/RelContextDialog.java	(revision 32398)
@@ -70,9 +70,8 @@
 import org.openstreetmap.josm.data.osm.event.SelectionEventManager;
 import org.openstreetmap.josm.gui.DefaultNameFormatter;
-import org.openstreetmap.josm.gui.MapView;
-import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener;
 import org.openstreetmap.josm.gui.OsmPrimitivRenderer;
 import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
-import org.openstreetmap.josm.gui.layer.OsmDataLayer;
+import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
+import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingComboBox;
 import org.openstreetmap.josm.tools.GBC;
@@ -102,5 +101,5 @@
  * @author Zverik
  */
-public class RelContextDialog extends ToggleDialog implements EditLayerChangeListener, ChosenRelationListener, SelectionChangedListener {
+public class RelContextDialog extends ToggleDialog implements ActiveLayerChangeListener, ChosenRelationListener, SelectionChangedListener {
 
     public static final String PREF_PREFIX = "reltoolbox";
@@ -136,5 +135,6 @@
         final JTable relationsTable = new JTable(relationsData);
         configureRelationsTable(relationsTable);
-        rcPanel.add(new JScrollPane(relationsTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), BorderLayout.CENTER);
+        rcPanel.add(new JScrollPane(relationsTable,
+                JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), BorderLayout.CENTER);
 
         final MouseListener relationMouseAdapter = new ChosenRelationMouseAdapter();
@@ -146,5 +146,5 @@
             @Override
             public void itemStateChanged(ItemEvent e) {
-                if (e.getStateChange() == ItemEvent.DESELECTED ) return;
+                if (e.getStateChange() == ItemEvent.DESELECTED) return;
                 String memberRole = roleBoxModel.getSelectedMembersRole();
                 String selectedRole = roleBoxModel.isAnotherRoleSelected() ? askForRoleName() : roleBoxModel.getSelectedRole();
@@ -200,5 +200,5 @@
         });
         downloadButton.setVisible(false);
-        if (Main.pref.getBoolean(PREF_PREFIX + ".hidetopline", false) ) {
+        if (Main.pref.getBoolean(PREF_PREFIX + ".hidetopline", false)) {
             chosenRelationPanel.setVisible(false);
         }
@@ -229,5 +229,5 @@
 
             private void checkPopup(MouseEvent e) {
-                if (e.isPopupTrigger() ) {
+                if (e.isPopupTrigger()) {
                     multiPopupMenu.show(e.getComponent(), e.getX(), e.getY());
                 }
@@ -249,7 +249,7 @@
                 int row = relationsTable.rowAtPoint(p);
                 if (SwingUtilities.isLeftMouseButton(e) && row >= 0) {
-                    Relation relation = (Relation)relationsData.getValueAt(row, 0);
+                    Relation relation = (Relation) relationsData.getValueAt(row, 0);
                     if (e.getClickCount() > 1) {
-                        Main.main.getEditLayer().data.setSelected(relation);
+                        Main.getLayerManager().getEditLayer().data.setSelected(relation);
                     }
                 }
@@ -271,5 +271,5 @@
                     int row = relationsTable.rowAtPoint(p);
                     if (row > -1) {
-                        Relation relation = (Relation)relationsData.getValueAt(row, 0);
+                        Relation relation = (Relation) relationsData.getValueAt(row, 0);
                         JPopupMenu menu = chosenRelation.isSame(relation) ? popupMenu
                                 : new ChosenRelationPopupMenu(new StaticChosenRelation(relation));
@@ -288,7 +288,8 @@
 
             @Override
-            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
+                    int row, int column) {
                 Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
-                if (!isSelected && value instanceof Relation && chosenRelation.isSame(value) ) {
+                if (!isSelected && value instanceof Relation && chosenRelation.isSame(value)) {
                     c.setBackground(CHOSEN_RELATION_COLOR);
                 } else {
@@ -301,7 +302,8 @@
         columns.getColumn(1).setCellRenderer(new DefaultTableCellRenderer() {
             @Override
-            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
+                    int row, int column) {
                 Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
-                if (!isSelected && chosenRelation.isSame(table.getValueAt(row, 0)) ) {
+                if (!isSelected && chosenRelation.isSame(table.getValueAt(row, 0))) {
                     c.setBackground(CHOSEN_RELATION_COLOR);
                 } else {
@@ -318,5 +320,5 @@
                 int selectedRow = relationsTable.getSelectedRow();
                 if (selectedRow >= 0) {
-                    chosenRelation.set((Relation)relationsData.getValueAt(selectedRow, 0));
+                    chosenRelation.set((Relation) relationsData.getValueAt(selectedRow, 0));
                     relationsTable.clearSelection();
                 }
@@ -334,5 +336,5 @@
     public void hideNotify() {
         SelectionEventManager.getInstance().removeSelectionListener(this);
-        MapView.removeEditLayerChangeListener(this);
+        Main.getLayerManager().removeActiveLayerChangeListener(this);
         DatasetEventManager.getInstance().removeDatasetListener(chosenRelation);
         chosenRelation.clear();
@@ -342,5 +344,5 @@
     public void showNotify() {
         SelectionEventManager.getInstance().addSelectionListener(this, FireMode.IN_EDT_CONSOLIDATED);
-        MapView.addEditLayerChangeListener(this);
+        Main.getLayerManager().addActiveLayerChangeListener(this);
         DatasetEventManager.getInstance().addDatasetListener(chosenRelation, FireMode.IN_EDT);
     }
@@ -352,17 +354,16 @@
     @Override
     public void chosenRelationChanged(Relation oldRelation, Relation newRelation) {
-        if (chosenRelationPanel != null && Main.pref.getBoolean(PREF_PREFIX + ".hidetopline", false) ) {
+        if (chosenRelationPanel != null && Main.pref.getBoolean(PREF_PREFIX + ".hidetopline", false)) {
             chosenRelationPanel.setVisible(newRelation != null);
         }
-        if (Main.main.getCurrentDataSet() != null ) {
-            selectionChanged(Main.main.getCurrentDataSet().getSelected());
+        if (Main.getLayerManager().getEditDataSet() != null) {
+            selectionChanged(Main.getLayerManager().getEditDataSet().getSelected());
         }
         roleBoxModel.update();
-        // ?
     }
 
     @Override
     public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
-        if (!isVisible() || relationsData == null )
+        if (!isVisible() || relationsData == null)
             return;
         roleBoxModel.update();
@@ -370,5 +371,5 @@
         relationsData.setRowCount(0);
         sortAndFixAction.chosenRelationChanged(chosenRelation.get(), chosenRelation.get());
-        if (newSelection == null )
+        if (newSelection == null)
             return;
 
@@ -388,5 +389,5 @@
                 for (OsmPrimitive element : newSelection) {
                     if (m.getMember().equals(element)) {
-                        if (role == null ) {
+                        if (role == null) {
                             role = m.getRole();
                         } else if (!role.equals(m.getRole())) {
@@ -399,20 +400,21 @@
             relationsData.addRow(new Object[] {rel, role == null ? "" : role});
         }
-        for (OsmPrimitive element : newSelection )
-            if (element instanceof Relation && !chosenRelation.isSame(element) ) {
+        for (OsmPrimitive element : newSelection) {
+            if (element instanceof Relation && !chosenRelation.isSame(element)) {
                 relationsData.addRow(new Object[] {element, ""});
             }
+        }
     }
 
     private void updateSelection() {
-        if (Main.main.getCurrentDataSet() == null) {
+        if (Main.getLayerManager().getEditDataSet() == null) {
             selectionChanged(Collections.<OsmPrimitive>emptyList());
         } else {
-            selectionChanged(Main.main.getCurrentDataSet().getSelected());
+            selectionChanged(Main.getLayerManager().getEditDataSet().getSelected());
         }
     }
 
     @Override
-    public void editLayerChanged(OsmDataLayer oldLayer, OsmDataLayer newLayer) {
+    public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
         updateSelection();
     }
@@ -435,9 +437,8 @@
 
         ClassLoader classLoader = RelContextDialog.class.getClassLoader();
-        try (
-                InputStream possibleRolesStream = classLoader.getResourceAsStream(POSSIBLE_ROLES_FILE);
+        try (InputStream possibleRolesStream = classLoader.getResourceAsStream(POSSIBLE_ROLES_FILE);
                 BufferedReader r = new BufferedReader(new InputStreamReader(possibleRolesStream));
                 ) {
-            while(r.ready()) {
+            while (r.ready()) {
                 String line = r.readLine();
                 StringTokenizer t = new StringTokenizer(line, " ,;:\"");
@@ -445,5 +446,5 @@
                     String type = t.nextToken();
                     List<String> roles = new ArrayList<>();
-                    while(t.hasMoreTokens() ) {
+                    while (t.hasMoreTokens()) {
                         roles.add(t.nextToken());
                     }
@@ -451,5 +452,5 @@
                 }
             }
-        } catch(Exception e) {
+        } catch (Exception e) {
             Main.error("[RelToolbox] Error reading possible roles file.");
             Main.error(e);
@@ -463,5 +464,5 @@
         List<String> items = new ArrayList<>();
         for (String role : roleBoxModel.getRoles()) {
-            if (role.length() > 1 ) {
+            if (role.length() > 1) {
                 items.add(role);
             }
@@ -497,5 +498,5 @@
         Object answer = optionPane.getValue();
         if (answer == null || answer == JOptionPane.UNINITIALIZED_VALUE
-                || (answer instanceof Integer && (Integer)answer != JOptionPane.OK_OPTION))
+                || (answer instanceof Integer && (Integer) answer != JOptionPane.OK_OPTION))
             return null;
 
@@ -506,7 +507,7 @@
         @Override
         public void mouseClicked(MouseEvent e) {
-            if (e.isControlDown() || !(e.getComponent() instanceof JComboBox ) ) // do not use left click handler on combo box
-                if (SwingUtilities.isLeftMouseButton(e) && chosenRelation.get() != null && Main.main.getEditLayer() != null) {
-                    Main.main.getEditLayer().data.setSelected(chosenRelation.get());
+            if (e.isControlDown() || !(e.getComponent() instanceof JComboBox)) // do not use left click handler on combo box
+                if (SwingUtilities.isLeftMouseButton(e) && chosenRelation.get() != null && Main.getLayerManager().getEditLayer() != null) {
+                    Main.getLayerManager().getEditLayer().data.setSelected(chosenRelation.get());
                 }
         }
@@ -530,5 +531,5 @@
 
     private class ChosenRelationPopupMenu extends JPopupMenu {
-        public ChosenRelationPopupMenu(ChosenRelation chosenRelation) {
+        ChosenRelationPopupMenu(ChosenRelation chosenRelation) {
             add(new SelectMembersAction(chosenRelation));
             add(new SelectRelationAction(chosenRelation));
@@ -545,6 +546,7 @@
 
     protected void applyRoleToSelection(String role) {
-        if (chosenRelation != null && chosenRelation.get() != null && Main.main.getCurrentDataSet() != null && !Main.main.getCurrentDataSet().selectionEmpty()) {
-            Collection<OsmPrimitive> selected = Main.main.getCurrentDataSet().getSelected();
+        if (chosenRelation != null && chosenRelation.get() != null
+                && Main.getLayerManager().getEditDataSet() != null && !Main.getLayerManager().getEditDataSet().selectionEmpty()) {
+            Collection<OsmPrimitive> selected = Main.getLayerManager().getEditDataSet().getSelected();
             Relation r = chosenRelation.get();
             List<Command> commands = new ArrayList<>();
@@ -553,5 +555,4 @@
                 if (selected.contains(m.getMember())) {
                     if (!role.equals(m.getRole())) {
-                        //                        r.setMember(i, new RelationMember(role, m.getMember()));
                         commands.add(new ChangeRelationMemberRoleCommand(r, i, role));
                     }
@@ -576,21 +577,7 @@
         }
     }
-    /*
-    private class MultipolygonSettingsAction extends AbstractAction {
-        public MultipolygonSettingsAction() {
-            super();
-            putValue(SMALL_ICON, ImageProvider.get("svpRight"));
-            putValue(SHORT_DESCRIPTION, tr("Change multipolygon creation settings"));
-        }
-
-        public void actionPerformed(ActionEvent e) {
-            Component c = e.getSource() instanceof Component ? (Component)e.getSource() : Main.parent;
-            multiPopupMenu.show(c, 0, 0);
-        }
-    }*/
 
     private class MultipolygonSettingsPopup extends JPopupMenu implements ActionListener {
-        public MultipolygonSettingsPopup() {
-            super();
+        MultipolygonSettingsPopup() {
             addMenuItem("boundary", tr("Create administrative boundary relations"));
             addMenuItem("boundaryways", tr("Add tags boundary and admin_level to boundary relation ways"));
@@ -614,5 +601,5 @@
             String property = e.getActionCommand();
             if (property != null && property.length() > 0 && e.getSource() instanceof JCheckBoxMenuItem) {
-                boolean value = ((JCheckBoxMenuItem)e.getSource()).isSelected();
+                boolean value = ((JCheckBoxMenuItem) e.getSource()).isSelected();
                 Main.pref.put(property, value);
                 show(getInvoker(), getX(), getY());
@@ -623,6 +610,6 @@
     private class EnterRoleAction extends JosmAction implements ChosenRelationListener {
 
-        public EnterRoleAction() {
-            super(tr("Change role"), (String)null, tr("Enter role for selected members"),
+        EnterRoleAction() {
+            super(tr("Change role"), (String) null, tr("Enter role for selected members"),
                     Shortcut.registerShortcut("reltoolbox:changerole", tr("Relation Toolbox: {0}", tr("Enter role for selected members")),
                             KeyEvent.VK_R, Shortcut.ALT_CTRL), false, "relcontext/enterrole", true);
@@ -635,5 +622,5 @@
             if (roleBoxModel.membersRole != null) {
                 String role = askForRoleName();
-                if (role != null ) {
+                if (role != null) {
                     applyRoleToSelection(role);
                 }
@@ -655,5 +642,5 @@
         private final String ANOTHER_ROLE = tr("another...");
 
-        public RoleComboBoxModel(JComboBox<String> combobox) {
+        RoleComboBoxModel(JComboBox<String> combobox) {
             super();
             this.combobox = combobox;
@@ -664,10 +651,10 @@
             membersRole = getSelectedMembersRoleIntl();
             if (membersRole == null) {
-                if (combobox.isEnabled() ) {
+                if (combobox.isEnabled()) {
                     combobox.setEnabled(false);
                 }
                 return;
             }
-            if (!combobox.isEnabled() ) {
+            if (!combobox.isEnabled()) {
                 combobox.setEnabled(true);
             }
@@ -681,15 +668,16 @@
                 if (chosenRelation.get().get("type") != null) {
                     List<String> values = possibleRoles.get(chosenRelation.get().get("type"));
-                    if (values != null ) {
+                    if (values != null) {
                         items.addAll(values);
                     }
                 }
-                for (RelationMember m : chosenRelation.get().getMembers() )
-                    if (m.getRole().length() > 0 && !items.contains(m.getRole()) ) {
+                for (RelationMember m : chosenRelation.get().getMembers()) {
+                    if (m.getRole().length() > 0 && !items.contains(m.getRole())) {
                         items.add(m.getRole());
                     }
+                }
             }
             items.add(EMPTY_ROLE);
-            if (!items.contains(membersRole) ) {
+            if (!items.contains(membersRole)) {
                 items.add(0, membersRole);
             }
@@ -697,5 +685,5 @@
             roles = Collections.unmodifiableList(items);
 
-            if (membersRole != null ) {
+            if (membersRole != null) {
                 setSelectedItem(membersRole);
             } else {
@@ -715,9 +703,10 @@
         private String getSelectedMembersRoleIntl() {
             String role = null;
-            if (chosenRelation != null && chosenRelation.get() != null && Main.main.getCurrentDataSet() != null && !Main.main.getCurrentDataSet().selectionEmpty()) {
-                Collection<OsmPrimitive> selected = Main.main.getCurrentDataSet().getSelected();
+            if (chosenRelation != null && chosenRelation.get() != null
+                    && Main.getLayerManager().getEditDataSet() != null && !Main.getLayerManager().getEditDataSet().selectionEmpty()) {
+                Collection<OsmPrimitive> selected = Main.getLayerManager().getEditDataSet().getSelected();
                 for (RelationMember m : chosenRelation.get().getMembers()) {
                     if (selected.contains(m.getMember())) {
-                        if (role == null ) {
+                        if (role == null) {
                             role = m.getRole();
                         } else if (m.getRole() != null && !role.equals(m.getRole())) {
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/AddRemoveMemberAction.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/AddRemoveMemberAction.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/AddRemoveMemberAction.java	(revision 32398)
@@ -13,4 +13,5 @@
 import org.openstreetmap.josm.command.ChangeCommand;
 import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -49,10 +50,10 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        if (rel.get() == null )
+        if (rel.get() == null)
             return;
 
         Relation r = new Relation(rel.get());
 
-        Collection<OsmPrimitive> toAdd = new ArrayList<>(getCurrentDataSet().getSelected());
+        Collection<OsmPrimitive> toAdd = new ArrayList<>(getLayerManager().getEditDataSet().getSelected());
         toAdd.remove(rel.get());
         toAdd.removeAll(r.getMemberPrimitives());
@@ -62,10 +63,10 @@
 
         // 1. remove all present members
-        r.removeMembersFor(getCurrentDataSet().getSelected());
+        r.removeMembersFor(getLayerManager().getEditDataSet().getSelected());
 
         // 2. add all new members
         for (OsmPrimitive p : toAdd) {
             int pos = -1; //p instanceof Way ? findAdjacentMember(p, r) : -1;
-            if (pos < 0 ) {
+            if (pos < 0) {
                 r.addMember(new RelationMember("", p));
             } else {
@@ -76,9 +77,9 @@
         // 3. check for roles again (temporary)
         Command roleFix = !isBroken && sortAndFix.needsFixing(r) ? sortAndFix.fixRelation(r) : null;
-        if (roleFix != null ) {
+        if (roleFix != null) {
             roleFix.executeCommand();
         }
 
-        if (!r.getMemberPrimitives().equals(rel.get().getMemberPrimitives()) ) {
+        if (!r.getMemberPrimitives().equals(rel.get().getMemberPrimitives())) {
             Main.main.undoRedo.add(new ChangeCommand(rel.get(), r));
         }
@@ -96,8 +97,8 @@
             for (int i = 0; i < r.getMembersCount(); i++) {
                 if (r.getMember(i).getType().equals(OsmPrimitiveType.WAY)) {
-                    Way rw = (Way)r.getMember(i).getMember();
+                    Way rw = (Way) r.getMember(i).getMember();
                     Node firstNodeR = rw.firstNode();
                     Node lastNodeR = rw.lastNode();
-                    if (firstNode.equals(firstNodeR) || firstNode.equals(lastNodeR) || lastNode.equals(firstNodeR) || lastNode.equals(lastNodeR) )
+                    if (firstNode.equals(firstNodeR) || firstNode.equals(lastNodeR) || lastNode.equals(firstNodeR) || lastNode.equals(lastNodeR))
                         return i + 1;
                 }
@@ -114,5 +115,5 @@
     @Override
     protected void updateEnabledState() {
-        updateEnabledState(getCurrentDataSet() == null ? null : getCurrentDataSet().getSelected());
+        updateEnabledState(getLayerManager().getEditDataSet() == null ? null : getLayerManager().getEditDataSet().getSelected());
     }
 
@@ -134,18 +135,19 @@
         // todo: change icon based on selection
         final int state; // 0=unknown, 1=add, 2=remove, 3=both
-        if (getCurrentDataSet() == null || getCurrentDataSet().getSelected() == null
-                || getCurrentDataSet().getSelected().isEmpty() || rel == null || rel.get() == null ) {
+        DataSet ds = getLayerManager().getEditDataSet();
+        if (ds == null || ds.getSelected() == null
+                || ds.getSelected().isEmpty() || rel == null || rel.get() == null) {
             state = 0;
         } else {
-            Collection<OsmPrimitive> toAdd = new ArrayList<>(getCurrentDataSet().getSelected());
+            Collection<OsmPrimitive> toAdd = new ArrayList<>(ds.getSelected());
             toAdd.remove(rel.get());
             int selectedSize = toAdd.size();
-            if (selectedSize == 0 ) {
+            if (selectedSize == 0) {
                 state = 0;
             } else {
                 toAdd.removeAll(rel.get().getMemberPrimitives());
-                if (toAdd.isEmpty() ) {
+                if (toAdd.isEmpty()) {
                     state = 2;
-                } else if (toAdd.size() < selectedSize ) {
+                } else if (toAdd.size() < selectedSize) {
                     state = 3;
                 } else {
@@ -157,8 +159,5 @@
             @Override
             public void run() {
-                //        String name = state == 0 ? "?" : state == 1 ? "+" : state == 2 ? "-" : "±";
-                //        putValue(Action.NAME, name);
                 if (state == 0) {
-                    //            putValue(NAME, "?");
                     putValue(LARGE_ICON_KEY, ImageProvider.get("relcontext", "addremove"));
                 } else {
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/CreateMultipolygonAction.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/CreateMultipolygonAction.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/CreateMultipolygonAction.java	(revision 32398)
@@ -33,4 +33,5 @@
 import org.openstreetmap.josm.command.Command;
 import org.openstreetmap.josm.command.SequenceCommand;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.MultipolygonBuilder;
 import org.openstreetmap.josm.data.osm.Node;
@@ -68,15 +69,15 @@
 
     public static boolean getDefaultPropertyValue(String property) {
-        if (property.equals("boundary") )
+        if (property.equals("boundary"))
             return false;
-        else if (property.equals("boundaryways") )
+        else if (property.equals("boundaryways"))
             return true;
-        else if (property.equals("tags") )
+        else if (property.equals("tags"))
             return true;
-        else if (property.equals("alltags") )
+        else if (property.equals("alltags"))
             return false;
-        else if (property.equals("single") )
+        else if (property.equals("single"))
             return true;
-        else if (property.equals("allowsplit") )
+        else if (property.equals("allowsplit"))
             return false;
         throw new IllegalArgumentException(property);
@@ -90,16 +91,17 @@
     public void actionPerformed(ActionEvent e) {
         boolean isBoundary = getPref("boundary");
-        Collection<Way> selectedWays = getCurrentDataSet().getSelectedWays();
+        DataSet ds = getLayerManager().getEditDataSet();
+        Collection<Way> selectedWays = ds.getSelectedWays();
         if (!isBoundary && getPref("tags")) {
             List<Relation> rels = null;
             if (getPref("allowsplit") || selectedWays.size() == 1) {
-                if (SplittingMultipolygons.canProcess(selectedWays) ) {
-                    rels = SplittingMultipolygons.process(getCurrentDataSet().getSelectedWays());
+                if (SplittingMultipolygons.canProcess(selectedWays)) {
+                    rels = SplittingMultipolygons.process(ds.getSelectedWays());
                 }
             } else {
                 if (TheRing.areAllOfThoseRings(selectedWays)) {
                     List<Command> commands = new ArrayList<>();
-                    rels = TheRing.makeManySimpleMultipolygons(getCurrentDataSet().getSelectedWays(), commands);
-                    if (!commands.isEmpty() ) {
+                    rels = TheRing.makeManySimpleMultipolygons(ds.getSelectedWays(), commands);
+                    if (!commands.isEmpty()) {
                         Main.main.undoRedo.add(new SequenceCommand(tr("Create multipolygons from rings"), commands));
                     }
@@ -107,11 +109,11 @@
             }
             if (rels != null && !rels.isEmpty()) {
-                if (chRel != null ) {
+                if (chRel != null) {
                     chRel.set(rels.size() == 1 ? rels.get(0) : null);
                 }
-                if (rels.size() == 1 ) {
-                    getCurrentDataSet().setSelected(rels);
+                if (rels.size() == 1) {
+                    ds.setSelected(rels);
                 } else {
-                    getCurrentDataSet().clearSelection();
+                    ds.clearSelection();
                 }
                 return;
@@ -121,5 +123,5 @@
         // for now, just copying standard action
         MultipolygonBuilder mpc = new MultipolygonBuilder();
-        String error = mpc.makeFromWays(getCurrentDataSet().getSelectedWays());
+        String error = mpc.makeFromWays(getLayerManager().getEditDataSet().getSelectedWays());
         if (error != null) {
             JOptionPane.showMessageDialog(Main.parent, error);
@@ -133,11 +135,11 @@
             rel.put("type", "multipolygon");
         }
-        for (MultipolygonBuilder.JoinedPolygon poly : mpc.outerWays ) {
-            for (Way w : poly.ways ) {
+        for (MultipolygonBuilder.JoinedPolygon poly : mpc.outerWays) {
+            for (Way w : poly.ways) {
                 rel.addMember(new RelationMember("outer", w));
             }
         }
-        for (MultipolygonBuilder.JoinedPolygon poly : mpc.innerWays ) {
-            for (Way w : poly.ways ) {
+        for (MultipolygonBuilder.JoinedPolygon poly : mpc.innerWays) {
+            for (Way w : poly.ways) {
                 rel.addMember(new RelationMember("inner", w));
             }
@@ -149,8 +151,8 @@
         }
         if (isBoundary) {
-            if (!askForAdminLevelAndName(rel) )
+            if (!askForAdminLevelAndName(rel))
                 return;
             addBoundaryMembers(rel);
-            if (getPref("boundaryways") ) {
+            if (getPref("boundaryways")) {
                 list.addAll(fixWayTagsForBoundary(rel));
             }
@@ -159,17 +161,17 @@
         Main.main.undoRedo.add(new SequenceCommand(tr("Create multipolygon"), list));
 
-        if (chRel != null ) {
+        if (chRel != null) {
             chRel.set(rel);
         }
 
-        getCurrentDataSet().setSelected(rel);
+        getLayerManager().getEditDataSet().setSelected(rel);
     }
 
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
+        if (getLayerManager().getEditDataSet() == null) {
             setEnabled(false);
         } else {
-            updateEnabledState(getCurrentDataSet().getSelected());
+            updateEnabledState(getLayerManager().getEditDataSet().getSelected());
         }
     }
@@ -178,5 +180,5 @@
     protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
         boolean isEnabled = true;
-        if (selection == null || selection.isEmpty() ) {
+        if (selection == null || selection.isEmpty()) {
             isEnabled = false;
         } else {
@@ -197,12 +199,12 @@
      */
     private void addBoundaryMembers(Relation rel) {
-        for (OsmPrimitive p : getCurrentDataSet().getSelected()) {
+        for (OsmPrimitive p : getLayerManager().getEditDataSet().getSelected()) {
             String role = null;
             if (p.getType().equals(OsmPrimitiveType.RELATION)) {
                 role = "subarea";
             } else if (p.getType().equals(OsmPrimitiveType.NODE)) {
-                Node n = (Node)p;
+                Node n = (Node) p;
                 if (!n.isIncomplete()) {
-                    if (n.hasKey("place") ) {
+                    if (n.hasKey("place")) {
                         role = "admin_centre";
                     } else {
@@ -211,5 +213,5 @@
                 }
             }
-            if (role != null ) {
+            if (role != null) {
                 rel.addMember(new RelationMember(role, p));
             }
@@ -222,5 +224,5 @@
     private List<Command> fixWayTagsForBoundary(Relation rel) {
         List<Command> commands = new ArrayList<>();
-        if (!rel.hasKey("boundary") || !rel.hasKey("admin_level") )
+        if (!rel.hasKey("boundary") || !rel.hasKey("admin_level"))
             return commands;
         String adminLevelStr = rel.get("admin_level");
@@ -228,5 +230,5 @@
         try {
             adminLevel = Integer.parseInt(adminLevelStr);
-        } catch(NumberFormatException e) {
+        } catch (NumberFormatException e) {
             return commands;
         }
@@ -236,12 +238,12 @@
             if (p instanceof Way) {
                 int count = 0;
-                if (p.hasKey("boundary") && p.get("boundary").equals("administrative") ) {
+                if (p.hasKey("boundary") && p.get("boundary").equals("administrative")) {
                     count++;
                 }
-                if (p.hasKey("admin_level") ) {
+                if (p.hasKey("admin_level")) {
                     count++;
                 }
                 if (p.keySet().size() - count == 0) {
-                    if (!p.hasKey("boundary") ) {
+                    if (!p.hasKey("boundary")) {
                         waysBoundary.add(p);
                     }
@@ -251,8 +253,8 @@
                         try {
                             int oldAdminLevel = Integer.parseInt(p.get("admin_level"));
-                            if (oldAdminLevel > adminLevel ) {
+                            if (oldAdminLevel > adminLevel) {
                                 waysAdminLevel.add(p);
                             }
-                        } catch(NumberFormatException e) {
+                        } catch (NumberFormatException e) {
                             waysAdminLevel.add(p); // some garbage, replace it
                         }
@@ -261,13 +263,15 @@
             }
         }
-        if (!waysBoundary.isEmpty() ) {
+        if (!waysBoundary.isEmpty()) {
             commands.add(new ChangePropertyCommand(waysBoundary, "boundary", "administrative"));
         }
-        if (!waysAdminLevel.isEmpty() ) {
+        if (!waysAdminLevel.isEmpty()) {
             commands.add(new ChangePropertyCommand(waysAdminLevel, "admin_level", adminLevelStr));
         }
         return commands;
     }
-    static public final List<String> DEFAULT_LINEAR_TAGS = Arrays.asList(new String[] {"barrier", "source"});
+
+    public static final List<String> DEFAULT_LINEAR_TAGS = Arrays.asList(new String[] {"barrier", "source"});
+
     private static final Set<String> REMOVE_FROM_BOUNDARY_TAGS = new TreeSet<>(Arrays.asList(new String[] {
             "boundary", "boundary_type", "type", "admin_level"
@@ -314,23 +318,25 @@
         // filter out empty key conflicts - we need second iteration
         boolean isBoundary = getPref("boundary");
-        if (isBoundary || !getPref("alltags") ) {
-            for (RelationMember m : relation.getMembers() )
-                if (m.hasRole() && m.getRole().equals("outer") && m.isWay() ) {
-                    for (String key : values.keySet() )
-                        if (!m.getWay().hasKey(key) && !relation.hasKey(key) ) {
+        if (isBoundary || !getPref("alltags")) {
+            for (RelationMember m : relation.getMembers()) {
+                if (m.hasRole() && m.getRole().equals("outer") && m.isWay()) {
+                    for (String key : values.keySet()) {
+                        if (!m.getWay().hasKey(key) && !relation.hasKey(key)) {
                             conflictingKeys.add(key);
                         }
-                }
-        }
-
-        for (String key : conflictingKeys ) {
+                    }
+                }
+            }
+        }
+
+        for (String key : conflictingKeys) {
             values.remove(key);
         }
 
-        for (String linearTag : Main.pref.getCollection(PREF_MULTIPOLY + "lineartags", DEFAULT_LINEAR_TAGS) ) {
+        for (String linearTag : Main.pref.getCollection(PREF_MULTIPOLY + "lineartags", DEFAULT_LINEAR_TAGS)) {
             values.remove(linearTag);
         }
 
-        if (values.containsKey("natural") && values.get("natural").equals("coastline") ) {
+        if (values.containsKey("natural") && values.get("natural").equals("coastline")) {
             values.remove("natural");
         }
@@ -339,8 +345,9 @@
         if (isBoundary) {
             Set<String> keySet = new TreeSet<>(values.keySet());
-            for (String key : keySet )
-                if (!REMOVE_FROM_BOUNDARY_TAGS.contains(key) ) {
+            for (String key : keySet) {
+                if (!REMOVE_FROM_BOUNDARY_TAGS.contains(key)) {
                     values.remove(key);
                 }
+            }
         }
 
@@ -376,5 +383,5 @@
         if (moveTags) {
             // add those tag values to the relation
-            if (isBoundary ) {
+            if (isBoundary) {
                 values.put("name", name);
             }
@@ -384,5 +391,5 @@
                 if (!r2.hasKey(key) && !key.equals("area")
                         && (!isBoundary || key.equals("admin_level") || key.equals("name"))) {
-                    if (relation.isNew() ) {
+                    if (relation.isNew()) {
                         relation.put(key, values.get(key));
                     } else {
@@ -392,5 +399,5 @@
                 }
             }
-            if (fixed && !relation.isNew() ) {
+            if (fixed && !relation.isNew()) {
                 commands.add(new ChangeCommand(relation, r2));
             }
@@ -402,5 +409,5 @@
     /**
      *
-     * @param rel
+     * @param rel relation
      * @return false if user pressed "cancel".
      */
@@ -408,5 +415,5 @@
         String relAL = rel.get("admin_level");
         String relName = rel.get("name");
-        if (relAL != null && relName != null )
+        if (relAL != null && relName != null)
             return true;
 
@@ -421,5 +428,5 @@
 
         final JTextField name = new JTextField();
-        if (relName != null ) {
+        if (relName != null) {
             name.setText(relName);
         }
@@ -450,5 +457,5 @@
         Object answer = optionPane.getValue();
         if (answer == null || answer == JOptionPane.UNINITIALIZED_VALUE
-                || (answer instanceof Integer && (Integer)answer != JOptionPane.OK_OPTION))
+                || (answer instanceof Integer && (Integer) answer != JOptionPane.OK_OPTION))
             return false;
 
@@ -459,5 +466,5 @@
             Main.pref.put(PREF_MULTIPOLY + "lastadmin", admin_level);
         }
-        if (new_name.length() > 0 ) {
+        if (new_name.length() > 0) {
             rel.put("name", new_name);
         }
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/CreateRelationAction.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/CreateRelationAction.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/CreateRelationAction.java	(revision 32398)
@@ -56,12 +56,12 @@
     public void actionPerformed(ActionEvent e) {
         String type = askForType();
-        if (type == null )
+        if (type == null)
             return;
 
         Relation rel = new Relation();
-        if (type.length() > 0 ) {
+        if (type.length() > 0) {
             rel.put("type", type);
         }
-        for (OsmPrimitive selected : getCurrentDataSet().getSelected() ) {
+        for (OsmPrimitive selected : getLayerManager().getEditDataSet().getSelected()) {
             rel.addMember(new RelationMember("", selected));
         }
@@ -76,8 +76,8 @@
     @Override
     protected void updateEnabledState() {
-        if (getCurrentDataSet() == null) {
+        if (getLayerManager().getEditDataSet() == null) {
             setEnabled(false);
         } else {
-            updateEnabledState(getCurrentDataSet().getSelected());
+            updateEnabledState(getLayerManager().getEditDataSet().getSelected());
         }
     }
@@ -130,5 +130,5 @@
         Object answer = optionPane.getValue();
         if (answer == null || answer == JOptionPane.UNINITIALIZED_VALUE
-                || (answer instanceof Integer && (Integer)answer != JOptionPane.OK_OPTION))
+                || (answer instanceof Integer && (Integer) answer != JOptionPane.OK_OPTION))
             return null;
 
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DeleteChosenRelationAction.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DeleteChosenRelationAction.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DeleteChosenRelationAction.java	(revision 32398)
@@ -33,6 +33,6 @@
         Relation r = rel.get();
         rel.clear();
-        Command c = DeleteCommand.delete(Main.main.getEditLayer(), Collections.singleton(r), true, true);
-        if (c != null ) {
+        Command c = DeleteCommand.delete(Main.getLayerManager().getEditLayer(), Collections.singleton(r), true, true);
+        if (c != null) {
             Main.main.undoRedo.add(c);
         }
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DownloadChosenRelationAction.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DownloadChosenRelationAction.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DownloadChosenRelationAction.java	(revision 32398)
@@ -31,6 +31,4 @@
 
     public DownloadChosenRelationAction(ChosenRelation rel) {
-        super();
-        //        putValue(NAME, "D");
         putValue(SMALL_ICON, ImageProvider.get("relcontext", "download"));
         putValue(SHORT_DESCRIPTION, tr("Download incomplete members for the chosen relation"));
@@ -43,9 +41,8 @@
     public void actionPerformed(ActionEvent e) {
         Relation relation = rel.get();
-        if (relation == null || relation.isNew() ) return;
+        if (relation == null || relation.isNew()) return;
         int total = relation.getMembersCount();
         int incomplete = relation.getIncompleteMembers().size();
-        //        if (incomplete <= 5 || (incomplete <= 10 && incomplete * 3 < total) )
-        if (incomplete <= 10 && incomplete * 3 < total ) {
+        if (incomplete <= 10 && incomplete * 3 < total) {
             downloadIncomplete(relation);
         } else {
@@ -70,14 +67,14 @@
     protected void downloadMembers(Relation rel) {
         if (!rel.isNew()) {
-            Main.worker.submit(new DownloadRelationTask(Collections.singletonList(rel), Main.main.getEditLayer()));
+            Main.worker.submit(new DownloadRelationTask(Collections.singletonList(rel), Main.getLayerManager().getEditLayer()));
         }
     }
 
     protected void downloadIncomplete(Relation rel) {
-        if (rel.isNew() ) return;
+        if (rel.isNew()) return;
         Set<OsmPrimitive> ret = new HashSet<>();
         ret.addAll(rel.getIncompleteMembers());
-        if (ret.isEmpty() ) return;
-        Main.worker.submit(new DownloadRelationMemberTask(Collections.singletonList(rel), ret, Main.main.getEditLayer()));
+        if (ret.isEmpty()) return;
+        Main.worker.submit(new DownloadRelationMemberTask(Collections.singletonList(rel), ret, Main.getLayerManager().getEditLayer()));
     }
 }
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DownloadParentsAction.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DownloadParentsAction.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DownloadParentsAction.java	(revision 32398)
@@ -38,5 +38,5 @@
         this.rel = rel;
         rel.addChosenRelationListener(this);
-        setEnabled(rel.get() != null && Main.main.getEditLayer() != null);
+        setEnabled(rel.get() != null && Main.getLayerManager().getEditLayer() != null);
     }
 
@@ -44,28 +44,28 @@
     public void actionPerformed(ActionEvent e) {
         Relation relation = rel.get();
-        if (relation == null ) return;
+        if (relation == null) return;
         List<OsmPrimitive> objects = new ArrayList<>();
         objects.add(relation);
         objects.addAll(relation.getMemberPrimitives());
-        Main.worker.submit(new DownloadReferrersTask(Main.main.getEditLayer(), objects));
+        Main.worker.submit(new DownloadReferrersTask(Main.getLayerManager().getEditLayer(), objects));
     }
 
     @Override
     public void chosenRelationChanged(Relation oldRelation, Relation newRelation) {
-        setEnabled(newRelation != null && Main.main.getEditLayer() != null);
+        setEnabled(newRelation != null && Main.getLayerManager().getEditLayer() != null);
     }
 
     protected void downloadMembers(Relation rel) {
         if (!rel.isNew()) {
-            Main.worker.submit(new DownloadRelationTask(Collections.singletonList(rel), Main.main.getEditLayer()));
+            Main.worker.submit(new DownloadRelationTask(Collections.singletonList(rel), Main.getLayerManager().getEditLayer()));
         }
     }
 
     protected void downloadIncomplete(Relation rel) {
-        if (rel.isNew() ) return;
+        if (rel.isNew()) return;
         Set<OsmPrimitive> ret = new HashSet<>();
         ret.addAll(rel.getIncompleteMembers());
-        if (ret.isEmpty() ) return;
-        Main.worker.submit(new DownloadRelationMemberTask(Collections.singletonList(rel), ret, Main.main.getEditLayer()));
+        if (ret.isEmpty()) return;
+        Main.worker.submit(new DownloadRelationMemberTask(Collections.singletonList(rel), ret, Main.getLayerManager().getEditLayer()));
     }
 }
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DuplicateChosenRelationAction.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DuplicateChosenRelationAction.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DuplicateChosenRelationAction.java	(revision 32398)
@@ -34,6 +34,6 @@
         Main.main.undoRedo.add(new AddCommand(copy));
         rel.set(copy);
-        if (Main.main.getCurrentDataSet() != null ) {
-            Main.main.getCurrentDataSet().setSelected(copy);
+        if (Main.getLayerManager().getEditDataSet() != null) {
+            Main.getLayerManager().getEditDataSet().setSelected(copy);
         }
     }
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/EditChosenRelationAction.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/EditChosenRelationAction.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/EditChosenRelationAction.java	(revision 32398)
@@ -25,6 +25,4 @@
 
     public EditChosenRelationAction(ChosenRelation rel) {
-        super();
-        //        putValue(NAME, "E");
         putValue(SMALL_ICON, ImageProvider.get("dialogs/mappaint", "pencil"));
         putValue(SHORT_DESCRIPTION, tr("Open relation editor for the chosen relation"));
@@ -37,6 +35,6 @@
     public void actionPerformed(ActionEvent e) {
         Relation relation = rel.get();
-        if (relation == null ) return;
-        RelationEditor.getEditor(Main.main.getEditLayer(), relation, null).setVisible(true);
+        if (relation == null) return;
+        RelationEditor.getEditor(Main.getLayerManager().getEditLayer(), relation, null).setVisible(true);
     }
 
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/FindRelationAction.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/FindRelationAction.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/FindRelationAction.java	(revision 32398)
@@ -63,5 +63,6 @@
         relationsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
         relationsList.setCellRenderer(new OsmPrimitivRenderer());
-        panel.add(new JScrollPane(relationsList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), BorderLayout.CENTER);
+        panel.add(new JScrollPane(relationsList,
+                JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), BorderLayout.CENTER);
         panel.setPreferredSize(new Dimension(400, 400));
 
@@ -108,5 +109,5 @@
             @Override
             public void keyPressed(KeyEvent e) {
-                if (shouldForward(e) ) {
+                if (shouldForward(e)) {
                     relationsList.dispatchEvent(e);
                 }
@@ -115,5 +116,5 @@
             @Override
             public void keyReleased(KeyEvent e) {
-                if (shouldForward(e) ) {
+                if (shouldForward(e)) {
                     relationsList.dispatchEvent(e);
                 }
@@ -132,9 +133,9 @@
         Object answer = optionPane.getValue();
         if (answer == null || answer == JOptionPane.UNINITIALIZED_VALUE
-                || (answer instanceof Integer && (Integer)answer != JOptionPane.OK_OPTION))
+                || (answer instanceof Integer && (Integer) answer != JOptionPane.OK_OPTION))
             return;
 
         Relation r = relationsList.getSelectedValue();
-        if (r != null ) {
+        if (r != null) {
             chRel.set(r);
         }
@@ -143,5 +144,5 @@
     @Override
     protected void updateEnabledState() {
-        setEnabled(getCurrentDataSet() != null);
+        setEnabled(getLayerManager().getEditDataSet() != null);
     }
 
@@ -150,24 +151,27 @@
         if (keywords.length > 0) {
             List<String> filteredKeywords = new ArrayList<>(keywords.length);
-            for (String s : keywords )
-                if (s.length() > 0 ) {
+            for (String s : keywords) {
+                if (s.length() > 0) {
                     filteredKeywords.add(s.trim().toLowerCase());
                 }
+            }
             keywords = filteredKeywords.toArray(new String[0]);
         }
 
-        System.out.println("keywords.length = " + keywords.length);
-        for (int i = 0; i < keywords.length; i++ ) {
-            System.out.println("keyword["+i+"] = " + keywords[i]);
+        if (Main.isDebugEnabled()) {
+            Main.debug("keywords.length = " + keywords.length);
+            for (int i = 0; i < keywords.length; i++) {
+                Main.debug("keyword["+i+"] = " + keywords[i]);
+            }
         }
 
         List<Relation> relations = new ArrayList<>();
-        if (getEditLayer() != null) {
-            for (Relation r : getEditLayer().data.getRelations()) {
+        if (getLayerManager().getEditLayer() != null) {
+            for (Relation r : getLayerManager().getEditLayer().data.getRelations()) {
                 if (!r.isDeleted() && r.isVisible() && !r.isIncomplete()) {
                     boolean add = true;
                     for (int i = 0; i < keywords.length && add; i++) {
                         boolean ok = false;
-                        if (String.valueOf(r.getPrimitiveId().getUniqueId()).contains(keywords[i]) ) {
+                        if (String.valueOf(r.getPrimitiveId().getUniqueId()).contains(keywords[i])) {
                             ok = true;
                         } else {
@@ -180,9 +184,9 @@
                             }
                         }
-                        if (!ok ) {
+                        if (!ok) {
                             add = false;
                         }
                     }
-                    if (add ) {
+                    if (add) {
                         relations.add(r);
                     }
@@ -227,9 +231,9 @@
         public void setRelations(Collection<Relation> relations) {
             int selectedIndex = selectionModel.getMinSelectionIndex();
-            Relation sel =  selectedIndex < 0 ? null : getElementAt(selectedIndex);
+            Relation sel = selectedIndex < 0 ? null : getElementAt(selectedIndex);
 
             this.relations.clear();
             selectionModel.clearSelection();
-            if (relations != null ) {
+            if (relations != null) {
                 this.relations.addAll(relations);
             }
@@ -238,9 +242,9 @@
             if (sel != null) {
                 selectedIndex = this.relations.indexOf(sel);
-                if (selectedIndex >= 0 ) {
+                if (selectedIndex >= 0) {
                     selectionModel.addSelectionInterval(selectedIndex, selectedIndex);
                 }
             }
-            if (selectionModel.isSelectionEmpty() && !this.relations.isEmpty() ) {
+            if (selectionModel.isSelectionEmpty() && !this.relations.isEmpty()) {
                 selectionModel.addSelectionInterval(0, 0);
             }
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/PublicTransportHelper.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/PublicTransportHelper.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/PublicTransportHelper.java	(revision 32398)
@@ -7,23 +7,19 @@
 
 /**
+ * @author freeExec
  * @see http://wiki.openstreetmap.org/wiki/Key:public_transport
- */
-
-/**
- *
- * @author freeExec
  */
 public final class PublicTransportHelper {
 
-    public final static String PUBLIC_TRANSPORT = "public_transport";
-    public final static String STOP_POSITION = "stop_position";
-    public final static String STOP = "stop";
-    public final static String STOP_AREA = "stop_area";
-    public final static String PLATFORM = "platform";
-    public final static String HIGHWAY = "highway";
-    public final static String RAILWAY = "railway";
-    public final static String BUS_STOP = "bus_stop";
-    public final static String RAILWAY_HALT = "halt";
-    public final static String RAILWAY_STATION = "station";
+    public static final String PUBLIC_TRANSPORT = "public_transport";
+    public static final String STOP_POSITION = "stop_position";
+    public static final String STOP = "stop";
+    public static final String STOP_AREA = "stop_area";
+    public static final String PLATFORM = "platform";
+    public static final String HIGHWAY = "highway";
+    public static final String RAILWAY = "railway";
+    public static final String BUS_STOP = "bus_stop";
+    public static final String RAILWAY_HALT = "halt";
+    public static final String RAILWAY_STATION = "station";
 
     private PublicTransportHelper() {
@@ -54,6 +50,5 @@
                 String pt = p.get(PUBLIC_TRANSPORT);
                 if (STOP_POSITION.equals(pt)) return true;
-            }
-            else if (p.hasKey(RAILWAY)) {
+            } else if (p.hasKey(RAILWAY)) {
                 String rw = p.get(RAILWAY);
                 if (RAILWAY_HALT.equals(rw) || RAILWAY_STATION.equals(rw)) return true;
@@ -83,4 +78,5 @@
         return false;
     }
+
     public static boolean isWayPlatform(RelationMember m) {
         return isWayPlatform(m.getMember());
@@ -121,10 +117,11 @@
         if (result != null) return result;
         // try to get name by stop_area
-        for (OsmPrimitive refOp : prim.getReferrers())
+        for (OsmPrimitive refOp : prim.getReferrers()) {
             if (refOp.getType() == OsmPrimitiveType.RELATION
-            && refOp.hasTag(PUBLIC_TRANSPORT, STOP_AREA)) {
+                    && refOp.hasTag(PUBLIC_TRANSPORT, STOP_AREA)) {
                 result = refOp.getName();
                 if (result != null) return result;
             }
+        }
         return result;
     }
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ReconstructPolygonAction.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ReconstructPolygonAction.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ReconstructPolygonAction.java	(revision 32398)
@@ -60,5 +60,5 @@
         boolean wont = false;
         for (RelationMember m : r.getMembers()) {
-            if (m.isWay() ) {
+            if (m.isWay()) {
                 ways.add(m.getWay());
             } else {
@@ -67,5 +67,6 @@
         }
         if (wont) {
-            JOptionPane.showMessageDialog(Main.parent, tr("Multipolygon must consist only of ways"), tr("Reconstruct polygon"), JOptionPane.ERROR_MESSAGE);
+            JOptionPane.showMessageDialog(Main.parent,
+                    tr("Multipolygon must consist only of ways"), tr("Reconstruct polygon"), JOptionPane.ERROR_MESSAGE);
             return;
         }
@@ -79,5 +80,6 @@
 
         if (!mpc.innerWays.isEmpty()) {
-            JOptionPane.showMessageDialog(Main.parent, tr("Reconstruction of polygons can be done only from outer ways"), tr("Reconstruct polygon"), JOptionPane.ERROR_MESSAGE);
+            JOptionPane.showMessageDialog(Main.parent,
+                    tr("Reconstruction of polygons can be done only from outer ways"), tr("Reconstruct polygon"), JOptionPane.ERROR_MESSAGE);
             return;
         }
@@ -86,6 +88,6 @@
         List<Way> newSelection = new ArrayList<>();
         List<Command> commands = new ArrayList<>();
-        Command c = DeleteCommand.delete(Main.main.getEditLayer(), Collections.singleton(r), true, true);
-        if (c == null )
+        Command c = DeleteCommand.delete(Main.getLayerManager().getEditLayer(), Collections.singleton(r), true, true);
+        if (c == null)
             return;
         commands.add(c);
@@ -106,8 +108,9 @@
                 }
                 List<OsmPrimitive> referrers = w.getReferrers();
-                for (Iterator<OsmPrimitive> ref1 = relations.iterator(); ref1.hasNext(); )
-                    if (!referrers.contains(ref1.next()) ) {
+                for (Iterator<OsmPrimitive> ref1 = relations.iterator(); ref1.hasNext();) {
+                    if (!referrers.contains(ref1.next())) {
                         ref1.remove();
                     }
+                }
             }
             tags.putAll(r.getKeys());
@@ -123,5 +126,5 @@
                     keys.removeAll(IRRELEVANT_KEYS);
                     if (keys.isEmpty()) {
-                        if (candidateWay == null ) {
+                        if (candidateWay == null) {
                             candidateWay = w;
                         } else {
@@ -149,5 +152,5 @@
         Main.main.undoRedo.add(new SequenceCommand(tr("Reconstruct polygons from relation {0}",
                 r.getDisplayName(DefaultNameFormatter.getInstance())), commands));
-        Main.main.getCurrentDataSet().setSelected(newSelection);
+        Main.getLayerManager().getEditDataSet().setSelected(newSelection);
     }
 
@@ -158,10 +161,11 @@
 
     private boolean isSuitableRelation(Relation newRelation) {
-        if (newRelation == null || !"multipolygon".equals(newRelation.get("type")) || newRelation.getMembersCount() == 0 )
+        if (newRelation == null || !"multipolygon".equals(newRelation.get("type")) || newRelation.getMembersCount() == 0)
             return false;
         else {
-            for (RelationMember m : newRelation.getMembers() )
-                if ("inner".equals(m.getRole()) )
+            for (RelationMember m : newRelation.getMembers()) {
+                if ("inner".equals(m.getRole()))
                     return false;
+            }
             return true;
         }
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ReconstructRouteAction.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ReconstructRouteAction.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ReconstructRouteAction.java	(revision 32398)
@@ -33,8 +33,8 @@
  * @author freeExec
  */
-public class ReconstructRouteAction  extends AbstractAction implements ChosenRelationListener {
+public class ReconstructRouteAction extends AbstractAction implements ChosenRelationListener {
     private final ChosenRelation rel;
 
-    public ReconstructRouteAction (ChosenRelation rel) {
+    public ReconstructRouteAction(ChosenRelation rel) {
         super(tr("Reconstruct route"));
         putValue(SMALL_ICON, ImageProvider.get("dialogs", "filter"));
@@ -65,6 +65,5 @@
                                 m.getMember());
                 stopMembers.put(rm.getMember(), rm);
-            }
-            else if (PublicTransportHelper.isMemberPlatform(m)) {
+            } else if (PublicTransportHelper.isMemberPlatform(m)) {
                 RelationMember rm = new RelationMember(
                         m.hasRole() ? m.getRole() : PublicTransportHelper.PLATFORM,
@@ -81,6 +80,5 @@
                     platformMembers.put(platformName, nList);
                 }
-            }
-            else if (PublicTransportHelper.isMemberRouteway(m)) {
+            } else if (PublicTransportHelper.isMemberRouteway(m)) {
                 routeMembers.add(new RelationMember(m));
             } else {
@@ -93,9 +91,9 @@
         Node lastNode = null;
         for (int rIndex = 0; rIndex < routeMembers.size(); rIndex++) {
-            Way w = (Way)routeMembers.get(rIndex).getMember();
+            Way w = (Way) routeMembers.get(rIndex).getMember();
             boolean dirForward = false;
             if (lastNode == null) { // first segment
                 if (routeMembers.size() > 2) {
-                    Way nextWay = (Way)routeMembers.get(rIndex + 1).getMember();
+                    Way nextWay = (Way) routeMembers.get(rIndex + 1).getMember();
                     if (w.lastNode().equals(nextWay.lastNode()) || w.lastNode().equals(nextWay.firstNode())) {
                         dirForward = true;
@@ -106,5 +104,7 @@
                 } // else one segment - direction unknown
             } else {
-                if (lastNode.equals(w.firstNode())) { dirForward = true; lastNode = w.lastNode(); } else {
+                if (lastNode.equals(w.firstNode())) {
+                    dirForward = true; lastNode = w.lastNode();
+                } else {
                     lastNode = w.firstNode();
                 }
@@ -126,5 +126,7 @@
                         }
                         boolean existsPlatform = platformMembers.containsKey(stopName);
-                        if (!existsPlatform) { stopName = ""; } // find of the nameless
+                        if (!existsPlatform) {
+                            stopName = ""; // find of the nameless
+                        }
                         if (existsPlatform || platformMembers.containsKey(stopName)) {
                             List<RelationMember> lMember = platformMembers.get(stopName);
@@ -153,5 +155,7 @@
             String stopName = PublicTransportHelper.getNameViaStoparea(stop);
             boolean existsPlatform = platformMembers.containsKey(stopName);
-            if (!existsPlatform) { stopName = ""; } // find of the nameless
+            if (!existsPlatform) {
+                stopName = ""; // find of the nameless
+            }
             if (existsPlatform || platformMembers.containsKey(stopName)) {
                 List<RelationMember> lMember = platformMembers.get(stopName);
@@ -224,5 +228,5 @@
     }
 
-    private boolean isSuitableRelation (Relation newRelation) {
+    private boolean isSuitableRelation(Relation newRelation) {
         return !(newRelation == null || !"route".equals(newRelation.get("type")) || newRelation.getMembersCount() == 0);
     }
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/RelationHelpAction.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/RelationHelpAction.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/RelationHelpAction.java	(revision 32398)
@@ -45,5 +45,5 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        if (rel.get() == null )
+        if (rel.get() == null)
             return;
         try {
@@ -61,5 +61,5 @@
             uris.add(new URI(String.format("%sRelations", base)));
 
-            Main.worker.execute(new Runnable(){
+            Main.worker.execute(new Runnable() {
                 @Override
                 public void run() {
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SelectMembersAction.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SelectMembersAction.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SelectMembersAction.java	(revision 32398)
@@ -28,5 +28,5 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        Main.main.getEditLayer().data.setSelected(rel.get() == null ? null : rel.get().getMemberPrimitives());
+        Main.getLayerManager().getEditLayer().data.setSelected(rel.get() == null ? null : rel.get().getMemberPrimitives());
     }
 
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SelectRelationAction.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SelectRelationAction.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SelectRelationAction.java	(revision 32398)
@@ -29,5 +29,5 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        Main.main.getEditLayer().data.setSelected(rel.get() == null ? null : rel.get());
+        Main.getLayerManager().getEditLayer().data.setSelected(rel.get() == null ? null : rel.get());
     }
 
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SortAndFixAction.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SortAndFixAction.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SortAndFixAction.java	(revision 32398)
@@ -56,5 +56,5 @@
     public void actionPerformed(ActionEvent e) {
         Command c = fixRelation(rel.get());
-        if (c != null ) {
+        if (c != null) {
             Main.main.undoRedo.add(c);
         }
@@ -71,7 +71,8 @@
 
     private RelationFixer getFixer(Relation rel) {
-        for (RelationFixer fixer : fixers)
+        for (RelationFixer fixer : fixers) {
             if (fixer.isFixerApplicable(rel))
                 return fixer;
+        }
         return new NothingFixer();
     }
@@ -82,11 +83,11 @@
 
     protected static boolean isIncomplete(Relation r) {
-        if (r == null || r.isIncomplete() || r.isDeleted() )
+        if (r == null || r.isIncomplete() || r.isDeleted())
             return true;
-        for (RelationMember m : r.getMembers())
-            if (m.getMember().isIncomplete() )
+        for (RelationMember m : r.getMembers()) {
+            if (m.getMember().isIncomplete())
                 return true;
+        }
         return false;
     }
-
 }
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SplittingMultipolygons.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SplittingMultipolygons.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SplittingMultipolygons.java	(revision 32398)
@@ -33,20 +33,24 @@
  * @author Zverik
  */
-public class SplittingMultipolygons {
+public final class SplittingMultipolygons {
     private static final String PREF_MULTIPOLY = "reltoolbox.multipolygon.";
+
+    private SplittingMultipolygons() {
+        // Hide default constructor for utilities classes
+    }
 
     public static boolean canProcess(Collection<Way> ways) {
         List<Way> rings = new ArrayList<>();
         List<Way> arcs = new ArrayList<>();
-        Area a = Main.main.getCurrentDataSet().getDataSourceArea();
+        Area a = Main.getLayerManager().getEditDataSet().getDataSourceArea();
         for (Way way : ways) {
-            if (way.isDeleted() )
+            if (way.isDeleted())
                 return false;
             for (Node n : way.getNodes()) {
                 LatLon ll = n.getCoor();
-                if (n.isIncomplete() || (a != null && !a.contains(ll.getX(), ll.getY())) )
+                if (n.isIncomplete() || (a != null && !a.contains(ll.getX(), ll.getY())))
                     return false;
             }
-            if (way.isClosed() ) {
+            if (way.isClosed()) {
                 rings.add(way);
             } else {
@@ -59,14 +63,15 @@
             for (Way segment : arcs) {
                 boolean found = false;
-                for (Way ring : rings )
-                    if (ring.containsNode(segment.firstNode()) && ring.containsNode(segment.lastNode()) ) {
+                for (Way ring : rings) {
+                    if (ring.containsNode(segment.firstNode()) && ring.containsNode(segment.lastNode())) {
                         found = true;
                     }
-                if (!found )
+                }
+                if (!found)
                     return false;
             }
         }
 
-        if (rings.isEmpty() && arcs.isEmpty() )
+        if (rings.isEmpty() && arcs.isEmpty())
             return false;
 
@@ -75,5 +80,5 @@
             for (int j = i + 1; j < rings.size(); j++) {
                 PolygonIntersection intersection = Geometry.polygonIntersection(rings.get(i).getNodes(), rings.get(j).getNodes());
-                if (intersection == PolygonIntersection.FIRST_INSIDE_SECOND || intersection == PolygonIntersection.SECOND_INSIDE_FIRST )
+                if (intersection == PolygonIntersection.FIRST_INSIDE_SECOND || intersection == PolygonIntersection.SECOND_INSIDE_FIRST)
                     return false;
             }
@@ -84,10 +89,9 @@
 
     public static List<Relation> process(Collection<Way> selectedWays) {
-        //    System.out.println("---------------------------------------");
         List<Relation> result = new ArrayList<>();
         List<Way> rings = new ArrayList<>();
         List<Way> arcs = new ArrayList<>();
         for (Way way : selectedWays) {
-            if (way.isClosed() ) {
+            if (way.isClosed()) {
                 rings.add(way);
             } else {
@@ -148,5 +152,5 @@
     public static List<Way> splitWay(Way w, Node n1, Node n2, List<Command> commands) {
         List<Node> nodes = new ArrayList<>(w.getNodes());
-        if (w.isClosed() ) {
+        if (w.isClosed()) {
             nodes.remove(nodes.size() - 1);
         }
@@ -159,7 +163,7 @@
         }
         // right now index2 >= index1
-        if (index2 < 1 || index1 >= w.getNodesCount() - 1 || index2 >= w.getNodesCount() )
+        if (index2 < 1 || index1 >= w.getNodesCount() - 1 || index2 >= w.getNodesCount())
             return Collections.emptyList();
-        if (w.isClosed() && (index1 < 0 || index1 == index2 || index1 + w.getNodesCount() == index2) )
+        if (w.isClosed() && (index1 < 0 || index1 == index2 || index1 + w.getNodesCount() == index2))
             return Collections.emptyList();
 
@@ -183,14 +187,7 @@
             chunks.get(chunks.size() - 1).addAll(chunks.get(0));
             chunks.remove(0);
-        } else if (chunks.get(chunks.size() - 1).size() < 2 ) {
+        } else if (chunks.get(chunks.size() - 1).size() < 2) {
             chunks.remove(chunks.size() - 1);
         }
-
-        // todo remove debug: show chunks array contents
-        /*for (List<Node> c1 : chunks) {
-    for (Node cn1 : c1 )
-    System.out.print(cn1.getId() + ",");
-    System.out.println();
-    }*/
 
         // build a map of referencing relations
@@ -199,12 +196,13 @@
         for (OsmPrimitive p : w.getReferrers()) {
             if (p instanceof Relation) {
-                Relation rel = commands == null ? (Relation)p : new Relation((Relation)p);
-                if (commands != null ) {
+                Relation rel = commands == null ? (Relation) p : new Relation((Relation) p);
+                if (commands != null) {
                     relationCommands.add(new ChangeCommand(p, rel));
                 }
-                for (int i = 0; i < rel.getMembersCount(); i++ )
-                    if (rel.getMember(i).getMember().equals(w) ) {
+                for (int i = 0; i < rel.getMembersCount(); i++) {
+                    if (rel.getMember(i).getMember().equals(w)) {
                         references.put(rel, Integer.valueOf(i));
                     }
+                }
             }
         }
@@ -229,9 +227,9 @@
             }
             newWay.setNodes(achunk);
-            if (commands != null ) {
+            if (commands != null) {
                 commands.add(new AddCommand(newWay));
             }
         }
-        if (commands != null ) {
+        if (commands != null) {
             commands.addAll(relationCommands);
         }
@@ -247,5 +245,5 @@
      */
     public static Relation tryToCloseOneWay(Way segment, List<Command> resultingCommands) {
-        if (segment.isClosed() || segment.isIncomplete() )
+        if (segment.isClosed() || segment.isIncomplete())
             return null;
 
@@ -256,13 +254,14 @@
         for (Iterator<Way> iter = ways.iterator(); iter.hasNext();) {
             boolean save = false;
-            for (OsmPrimitive ref : iter.next().getReferrers() )
-                if (ref instanceof Relation && ((Relation)ref).isMultipolygon() && !ref.isDeleted() ) {
+            for (OsmPrimitive ref : iter.next().getReferrers()) {
+                if (ref instanceof Relation && ((Relation) ref).isMultipolygon() && !ref.isDeleted()) {
                     save = true;
                 }
-            if (!save ) {
+            }
+            if (!save) {
                 iter.remove();
             }
         }
-        if (ways.isEmpty() )
+        if (ways.isEmpty())
             return null; // well...
         Way target = ways.get(0);
@@ -283,5 +282,5 @@
             }
         }
-        if (changed ) {
+        if (changed) {
             commands.add(new ChangeCommand(segment, segmentCopy));
         }
@@ -318,8 +317,9 @@
     private static <T> List<T> intersection(Collection<T> list1, Collection<T> list2) {
         List<T> result = new ArrayList<>();
-        for (T item : list1 )
-            if (list2.contains(item) ) {
+        for (T item : list1) {
+            if (list2.contains(item)) {
                 result.add(item);
             }
+        }
         return result;
     }
@@ -329,5 +329,5 @@
      */
     public static Relation attachRingToNeighbours(Way ring, List<Command> resultingCommands) {
-        if (!ring.isClosed() || ring.isIncomplete() )
+        if (!ring.isClosed() || ring.isIncomplete())
             return null;
         Map<Way, Boolean> touchingWays = new HashMap<>();
@@ -336,9 +336,9 @@
                 if (p instanceof Way && !p.equals(ring)) {
                     for (OsmPrimitive r : p.getReferrers()) {
-                        if (r instanceof Relation && ((Relation)r).hasKey("type") && ((Relation)r).get("type").equals("multipolygon")) {
-                            if (touchingWays.containsKey(p) ) {
-                                touchingWays.put((Way)p, Boolean.TRUE);
+                        if (r instanceof Relation && ((Relation) r).hasKey("type") && ((Relation) r).get("type").equals("multipolygon")) {
+                            if (touchingWays.containsKey(p)) {
+                                touchingWays.put((Way) p, Boolean.TRUE);
                             } else {
-                                touchingWays.put((Way)p, Boolean.FALSE);
+                                touchingWays.put((Way) p, Boolean.FALSE);
                             }
                             break;
@@ -350,14 +350,9 @@
 
         List<TheRing> otherWays = new ArrayList<>();
-        for (Way w : touchingWays.keySet() )
+        for (Way w : touchingWays.keySet()) {
             if (touchingWays.get(w)) {
                 otherWays.add(new TheRing(w));
-                //        System.out.println("Touching ring: " + otherWays.get(otherWays.size()-1));
-            }
-
-        //    for (Iterator<Way> keys = touchingWays.keySet().iterator(); keys.hasNext();) {
-        //        if (!touchingWays.get(keys.next()) )
-        //        keys.remove();
-        //    }
+            }
+        }
 
         // now touchingWays has only ways that touch the ring twice
@@ -365,15 +360,15 @@
         TheRing theRing = new TheRing(ring); // this is actually useful
 
-        for (TheRing otherRing : otherWays ) {
+        for (TheRing otherRing : otherWays) {
             theRing.collide(otherRing);
         }
 
         theRing.putSourceWayFirst();
-        for (TheRing otherRing : otherWays ) {
+        for (TheRing otherRing : otherWays) {
             otherRing.putSourceWayFirst();
         }
 
         Map<Relation, Relation> relationCache = new HashMap<>();
-        for (TheRing otherRing : otherWays ) {
+        for (TheRing otherRing : otherWays) {
             commands.addAll(otherRing.getCommands(false, relationCache));
         }
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/TheRing.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/TheRing.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/TheRing.java	(revision 32398)
@@ -1,4 +1,6 @@
 // License: GPL. For details, see LICENSE file.
 package relcontext.actions;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
 
 import java.util.ArrayList;
@@ -45,10 +47,10 @@
         List<Way> rings = new ArrayList<>();
         for (Way way : ways) {
-            if (way.isClosed() ) {
+            if (way.isClosed()) {
                 rings.add(way);
             } else
                 return false;
         }
-        if (rings.isEmpty() || ways.size() == 1 )
+        if (rings.isEmpty() || ways.size() == 1)
             return false;
 
@@ -57,5 +59,5 @@
             for (int j = i + 1; j < rings.size(); j++) {
                 PolygonIntersection intersection = Geometry.polygonIntersection(rings.get(i).getNodes(), rings.get(j).getNodes());
-                if (intersection == PolygonIntersection.FIRST_INSIDE_SECOND || intersection == PolygonIntersection.SECOND_INSIDE_FIRST )
+                if (intersection == PolygonIntersection.FIRST_INSIDE_SECOND || intersection == PolygonIntersection.SECOND_INSIDE_FIRST)
                     return false;
             }
@@ -72,9 +74,9 @@
         log("---------------------------------------");
         List<TheRing> rings = new ArrayList<>(selection.size());
-        for (Way w : selection ) {
+        for (Way w : selection) {
             rings.add(new TheRing(w));
         }
-        for (int i = 0; i < rings.size() - 1; i++ ) {
-            for (int j = i + 1; j < rings.size(); j++ ) {
+        for (int i = 0; i < rings.size() - 1; i++) {
+            for (int j = i + 1; j < rings.size(); j++) {
                 rings.get(i).collide(rings.get(j));
             }
@@ -108,10 +110,11 @@
                             RingSegment segment = splitRingAt(i, split[0], split[1]);
                             RingSegment otherSegment = other.splitRingAt(j, split[2], split[3]);
-                            if (!areSegmentsEqual(segment, otherSegment) )
-                                throw new IllegalArgumentException("Error: algorithm gave incorrect segments: " + segment + " and " + otherSegment);
+                            if (!areSegmentsEqual(segment, otherSegment))
+                                throw new IllegalArgumentException(
+                                        "Error: algorithm gave incorrect segments: " + segment + " and " + otherSegment);
                             segment.makeReference(otherSegment);
                         }
                     }
-                    if (segment1.isReference() ) {
+                    if (segment1.isReference()) {
                         break;
                     }
@@ -126,5 +129,5 @@
     public static Node[] getSplitNodes(List<Node> nodes1, List<Node> nodes2, boolean isRing1, boolean isRing2) {
         int pos = 0;
-        while(pos < nodes1.size() && !nodes2.contains(nodes1.get(pos)) ) {
+        while (pos < nodes1.size() && !nodes2.contains(nodes1.get(pos))) {
             pos++;
         }
@@ -133,9 +136,10 @@
             // rewind a bit
             pos = nodes1.size() - 1;
-            while(pos > 0 && nodes2.contains(nodes1.get(pos)) ) {
+            while (pos > 0 && nodes2.contains(nodes1.get(pos))) {
                 pos--;
             }
             if (pos == 0 && nodes1.size() == nodes2.size()) {
-                JOptionPane.showMessageDialog(Main.parent, "Two rings are equal, and this must not be.", "Multipolygon from rings", JOptionPane.ERROR_MESSAGE);
+                JOptionPane.showMessageDialog(Main.parent,
+                        tr("Two rings are equal, and this must not be."), tr("Multipolygon from rings"), JOptionPane.ERROR_MESSAGE);
                 return null;
             }
@@ -143,5 +147,5 @@
         }
         int firstPos = isRing1 ? pos : nodes1.size();
-        while(!collideFound) {
+        while (!collideFound) {
             log("pos=" + pos);
             int start1 = pos;
@@ -152,9 +156,9 @@
             if (last1 >= 0) {
                 last2 = incrementBy(start2, -1, nodes2.size(), isRing2);
-                if (last2 >= 0 && nodes1.get(last1).equals(nodes2.get(last2)) ) {
+                if (last2 >= 0 && nodes1.get(last1).equals(nodes2.get(last2))) {
                     increment2 = -1;
                 } else {
                     last2 = incrementBy(start2, 1, nodes2.size(), isRing2);
-                    if (last2 >= 0 && nodes1.get(last1).equals(nodes2.get(last2)) ) {
+                    if (last2 >= 0 && nodes1.get(last1).equals(nodes2.get(last2))) {
                         increment2 = 1;
                     }
@@ -165,8 +169,8 @@
                 // find the first nodes
                 boolean reachedEnd = false;
-                while(!reachedEnd) {
+                while (!reachedEnd) {
                     int newLast1 = incrementBy(last1, 1, nodes1.size(), isRing1);
                     int newLast2 = incrementBy(last2, increment2, nodes2.size(), isRing2);
-                    if (newLast1 < 0 || newLast2 < 0 || !nodes1.get(newLast1).equals(nodes2.get(newLast2)) ) {
+                    if (newLast1 < 0 || newLast2 < 0 || !nodes1.get(newLast1).equals(nodes2.get(newLast2))) {
                         reachedEnd = true;
                     } else {
@@ -184,8 +188,8 @@
             } else {
                 pos = last1;
-                while(pos != firstPos && pos >= 0 && !nodes2.contains(nodes1.get(pos)) ) {
+                while (pos != firstPos && pos >= 0 && !nodes2.contains(nodes1.get(pos))) {
                     pos = incrementBy(pos, 1, nodes1.size(), isRing1);
                 }
-                if (pos < 0 || pos == firstPos || !nodes2.contains(nodes1.get(pos)) ) {
+                if (pos < 0 || pos == firstPos || !nodes2.contains(nodes1.get(pos))) {
                     collideFound = true;
                 }
@@ -197,7 +201,7 @@
     private static int incrementBy(int value, int increment, int limit1, boolean isRing) {
         int result = value + increment;
-        if (result < 0 )
+        if (result < 0)
             return isRing ? result + limit1 : -1;
-        else if (result >= limit1 )
+        else if (result >= limit1)
             return isRing ? result - limit1 : -1;
         else
@@ -209,10 +213,11 @@
         List<Node> nodes2 = seg2.getNodes();
         int size = nodes1.size();
-        if (size != nodes2.size() )
+        if (size != nodes2.size())
             return false;
         boolean reverse = size > 1 && !nodes1.get(0).equals(nodes2.get(0));
-        for (int i = 0; i < size; i++ )
-            if (!nodes1.get(i).equals(nodes2.get(reverse ? size-1-i : i)) )
+        for (int i = 0; i < size; i++) {
+            if (!nodes1.get(i).equals(nodes2.get(reverse ? size-1-i : i)))
                 return false;
+        }
         return true;
     }
@@ -223,5 +228,5 @@
      */
     private RingSegment splitRingAt(int segmentIndex, Node n1, Node n2) {
-        if (n1.equals(n2) )
+        if (n1.equals(n2))
             throw new IllegalArgumentException("Both nodes are equal, id=" + n1.getUniqueId());
         RingSegment segment = segments.get(segmentIndex);
@@ -242,8 +247,8 @@
         // if thirdPart == null, then n2 == lastNode
         int pos = segmentIndex + 1;
-        if (secondPart != null ) {
+        if (secondPart != null) {
             segments.add(pos++, secondPart);
         }
-        if (thirdPart != null ) {
+        if (thirdPart != null) {
             segments.add(pos++, thirdPart);
         }
@@ -260,9 +265,10 @@
         // build segments map
         Map<RingSegment, TheRing> segmentMap = new HashMap<>();
-        for (TheRing ring : rings ) {
-            for (RingSegment seg : ring.segments )
-                if (!seg.isReference() ) {
+        for (TheRing ring : rings) {
+            for (RingSegment seg : ring.segments) {
+                if (!seg.isReference()) {
                     segmentMap.put(seg, ring);
                 }
+            }
         }
 
@@ -283,5 +289,5 @@
 
         // initializing source way for each ring
-        for (TheRing ring : rings ) {
+        for (TheRing ring : rings) {
             ring.putSourceWayFirst();
         }
@@ -290,8 +296,9 @@
     private int countNonReferenceSegments() {
         int count = 0;
-        for (RingSegment seg : segments )
-            if (!seg.isReference() ) {
+        for (RingSegment seg : segments) {
+            if (!seg.isReference()) {
                 count++;
             }
+        }
         return count;
     }
@@ -325,8 +332,8 @@
             relation.put("type", "multipolygon");
             for (String key : sourceCopy.keySet()) {
-                if (linearTags.contains(key) ) {
+                if (linearTags.contains(key)) {
                     continue;
                 }
-                if (key.equals("natural") && sourceCopy.get("natural").equals("coastline") ) {
+                if (key.equals("natural") && sourceCopy.get("natural").equals("coastline")) {
                     continue;
                 }
@@ -343,23 +350,21 @@
                 Relation rel = null;
                 if (relationChangeMap != null) {
-                    if (relationChangeMap.containsKey(p) ) {
+                    if (relationChangeMap.containsKey(p)) {
                         rel = relationChangeMap.get(p);
                     } else {
-                        rel = new Relation((Relation)p);
-                        relationChangeMap.put((Relation)p, rel);
+                        rel = new Relation((Relation) p);
+                        relationChangeMap.put((Relation) p, rel);
                     }
                 } else {
-                    rel = new Relation((Relation)p);
+                    rel = new Relation((Relation) p);
                     relationCommands.add(new ChangeCommand(p, rel));
                 }
-                for (int i = 0; i < rel.getMembersCount(); i++ )
-                    if (rel.getMember(i).getMember().equals(source) ) {
+                for (int i = 0; i < rel.getMembersCount(); i++) {
+                    if (rel.getMember(i).getMember().equals(source)) {
                         referencingRelations.put(rel, Integer.valueOf(i));
                     }
-            }
-        }
-        // todo: ÐºÐ¾Ð³Ð´Ð° Ð´Ð²Ð° ÐºÐ¾Ð»ÑŒÑ†Ð° Ð¼ÐµÐ½Ñ�ÑŽÑ‚ Ð¾Ð´Ð½Ð¾ Ð¸ Ñ‚Ð¾ Ð¶Ðµ Ð¾Ñ‚Ð½Ð¾ÑˆÐµÐ½Ð¸Ðµ, Ð² Ñ�Ð¿Ð¸Ñ�Ð¾Ðº ÐºÐ¾Ð¼Ð°Ð½Ð´ Ð´Ð¾Ð±Ð°Ð²Ð»Ñ�ÐµÑ‚Ñ�Ñ�
-        // Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ðµ Ð±Ð°Ð·Ð¾Ð²Ð¾Ð³Ð¾ Ð¾Ñ‚Ð½Ð¾ÑˆÐµÐ½Ð¸Ñ� Ð½Ð° Ð½Ð¾Ð²Ð¾Ðµ, Ð° Ð½Ðµ Ð¿Ñ€ÐµÐ´Ñ‹Ð´ÑƒÑ‰ÐµÐ³Ð¾
-        // Ð¿Ð¾Ñ�Ñ‚Ð¾Ð¼Ñƒ Ñ�Ð¾Ñ…Ñ€Ð°Ð½Ñ�ÐµÑ‚Ñ�Ñ� Ñ‚Ð¾Ð»ÑŒÐºÐ¾ Ð¿ÐµÑ€Ð²Ð¾Ðµ Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ðµ
+                }
+            }
+        }
 
         List<Command> commands = new ArrayList<>();
@@ -368,5 +373,5 @@
             boolean needAdding = !seg.isWayConstructed();
             Way w = seg.constructWay(seg.isReference() ? null : sourceCopy);
-            if (needAdding ) {
+            if (needAdding) {
                 commands.add(new AddCommand(w));
             }
@@ -383,13 +388,13 @@
                 }
             }
-            if (createMultipolygon ) {
+            if (createMultipolygon) {
                 relation.addMember(new RelationMember("outer", w));
             }
         }
-        if (!foundOwnWay ) {
+        if (!foundOwnWay) {
             commands.add(new DeleteCommand(source));
         }
         commands.addAll(relationCommands);
-        if (createMultipolygon ) {
+        if (createMultipolygon) {
             commands.add(new AddCommand(relation));
         }
@@ -398,5 +403,5 @@
 
     public static void updateCommandsWithRelations(List<Command> commands, Map<Relation, Relation> relationCache) {
-        for (Relation src : relationCache.keySet() ) {
+        for (Relation src : relationCache.keySet()) {
             commands.add(new ChangeCommand(src, relationCache.get(src)));
         }
@@ -414,9 +419,9 @@
         StringBuilder sb = new StringBuilder("TheRing@");
         sb.append(this.hashCode()).append('[').append("wayId: ").append(source == null ? "null" : source.getUniqueId()).append("; segments: ");
-        if (segments.isEmpty() ) {
+        if (segments.isEmpty()) {
             sb.append("empty");
         } else {
             sb.append(segments.get(0));
-            for (int i = 1; i < segments.size(); i++ ) {
+            for (int i = 1; i < segments.size(); i++) {
                 sb.append(", ").append(segments.get(i));
             }
@@ -425,29 +430,6 @@
     }
 
-    /**
-     * Appends "append" to "base" so the closed polygon forms.
-     */
-    /*private static void closePolygon(List<Node> base, List<Node> append) {
-    if (append.get(0).equals(base.get(0)) && append.get(append.size() - 1).equals(base.get(base.size() - 1))) {
-        List<Node> ap2 = new ArrayList<Node>(append);
-        Collections.reverse(ap2);
-        append = ap2;
-    }
-    base.remove(base.size() - 1);
-    base.addAll(append);
-    }*/
-
-    /**
-     * Checks if a middle point between two nodes is inside a polygon. Useful to check if the way is inside.
-     */
-    /*private static boolean segmentInsidePolygon(Node n1, Node n2, List<Node> polygon) {
-    EastNorth en1 = n1.getEastNorth();
-    EastNorth en2 = n2.getEastNorth();
-    Node testNode = new Node(new EastNorth((en1.east() + en2.east()) / 2.0, (en1.north() + en2.north()) / 2.0));
-    return Geometry.nodeInsidePolygon(testNode, polygon);
-    }*/
-
     private static void log(String s) {
-        //    System.out.println(s);
+        Main.debug(s);
     }
 
@@ -459,24 +441,16 @@
         private boolean isRing;
 
-        /*private RingSegment() {
-    }*/
-
-        public RingSegment(Way w) {
+        RingSegment(Way w) {
             this(w.getNodes());
         }
 
-        public RingSegment(List<Node> nodes) {
+        RingSegment(List<Node> nodes) {
             this.nodes = nodes;
             isRing = nodes.size() > 1 && nodes.get(0).equals(nodes.get(nodes.size() - 1));
-            if (isRing ) {
+            if (isRing) {
                 nodes.remove(nodes.size() - 1);
             }
             references = null;
         }
-
-        /*public RingSegment(RingSegment ref) {
-        this.nodes = null;
-        this.references = ref;
-    }*/
 
         /**
@@ -487,8 +461,8 @@
          */
         public RingSegment split(Node n) {
-            if (nodes == null )
+            if (nodes == null)
                 throw new IllegalArgumentException("Cannot split segment: it is a reference");
             int pos = nodes.indexOf(n);
-            if (pos <= 0 || pos >= nodes.size() - 1 )
+            if (pos <= 0 || pos >= nodes.size() - 1)
                 return null;
             List<Node> newNodes = new ArrayList<>(nodes.subList(pos, nodes.size()));
@@ -503,10 +477,10 @@
          */
         public RingSegment split(Node n1, Node n2) {
-            if (nodes == null )
+            if (nodes == null)
                 throw new IllegalArgumentException("Cannot split segment: it is a reference");
             if (!isRing) {
-                if (n1 == null || nodes.get(0).equals(n1) || nodes.get(nodes.size() - 1).equals(n1) )
+                if (n1 == null || nodes.get(0).equals(n1) || nodes.get(nodes.size() - 1).equals(n1))
                     return split(n2);
-                if (n2 == null || nodes.get(0).equals(n2) || nodes.get(nodes.size() - 1).equals(n2) )
+                if (n2 == null || nodes.get(0).equals(n2) || nodes.get(nodes.size() - 1).equals(n2))
                     return split(n1);
                 throw new IllegalArgumentException("Split for two nodes is called for not-ring: " + this);
@@ -514,5 +488,5 @@
             int pos1 = nodes.indexOf(n1);
             int pos2 = nodes.indexOf(n2);
-            if (pos1 == pos2 )
+            if (pos1 == pos2)
                 return null;
 
@@ -521,8 +495,8 @@
                 newNodes.addAll(nodes.subList(pos2, nodes.size()));
                 newNodes.addAll(nodes.subList(0, pos1 + 1));
-                if (pos2 + 1 < nodes.size() ) {
+                if (pos2 + 1 < nodes.size()) {
                     nodes.subList(pos2 + 1, nodes.size()).clear();
                 }
-                if (pos1 > 0 ) {
+                if (pos1 > 0) {
                     nodes.subList(0, pos1).clear();
                 }
@@ -541,8 +515,8 @@
 
         public List<Node> getWayNodes() {
-            if (nodes == null )
+            if (nodes == null)
                 throw new IllegalArgumentException("Won't give you wayNodes: it is a reference");
             List<Node> wayNodes = new ArrayList<>(nodes);
-            if (isRing ) {
+            if (isRing) {
                 wayNodes.add(wayNodes.get(0));
             }
@@ -576,5 +550,5 @@
 
         public Way constructWay(Way template) {
-            if (isReference() )
+            if (isReference())
                 return references.constructWay(template);
             if (resultingWay == null) {
@@ -590,5 +564,5 @@
 
         public void overrideWay(Way source) {
-            if (isReference() ) {
+            if (isReference()) {
                 references.overrideWay(source);
             } else {
@@ -598,26 +572,18 @@
         }
 
-        /**
-         * Compares two segments with respect to referencing.
-         * @return true if ways are equals, or one references another.
-         */
-        /*public boolean isReferencingEqual(RingSegment other) {
-        return this.equals(other) || (other.isReference() && other.references == this) || (isReference() && references == other);
-    }*/
-
         @Override
         public String toString() {
             StringBuilder sb = new StringBuilder("RingSegment@");
             sb.append(this.hashCode()).append('[');
-            if (isReference() ) {
+            if (isReference()) {
                 sb.append("references ").append(references.hashCode());
-            } else if (nodes.isEmpty() ) {
+            } else if (nodes.isEmpty()) {
                 sb.append("empty");
             } else {
-                if (isRing ) {
+                if (isRing) {
                     sb.append("ring:");
                 }
                 sb.append(nodes.get(0).getUniqueId());
-                for (int i = 1; i < nodes.size(); i++ ) {
+                for (int i = 1; i < nodes.size(); i++) {
                     sb.append(',').append(nodes.get(i).getUniqueId());
                 }
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/AssociatedStreetFixer.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/AssociatedStreetFixer.java	(revision 32397)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/AssociatedStreetFixer.java	(revision 32398)
@@ -90,5 +90,5 @@
                         (way.hasKey("building") || way.hasKey("addr:housenumber"))) {
                     fixed = true;
-                    rel.setMember(i,  new RelationMember("house", way));
+                    rel.setMember(i, new RelationMember("house", way));
                 }
             } else if (m.isRelation()) {
