Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/ChosenRelation.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/ChosenRelation.java	(revision 30737)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/ChosenRelation.java	(revision 30738)
@@ -150,6 +150,6 @@
                 }
             } else if( element.getType() == OsmPrimitiveType.RELATION ) {
-            	Color oldColor = g.getColor();
-            	g.setColor(Color.magenta);
+                Color oldColor = g.getColor();
+                g.setColor(Color.magenta);
                 drawRelations(g, mv, bbox, (Relation)element);
                 g.setColor(oldColor);
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/ChosenRelationListener.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/ChosenRelationListener.java	(revision 30737)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/ChosenRelationListener.java	(revision 30738)
@@ -9,4 +9,4 @@
  */
 public interface ChosenRelationListener {
-	void chosenRelationChanged( Relation oldRelation, Relation newRelation );
+    void chosenRelationChanged( Relation oldRelation, Relation newRelation );
 }
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/ExtraNameFormatHook.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/ExtraNameFormatHook.java	(revision 30737)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/ExtraNameFormatHook.java	(revision 30738)
@@ -14,31 +14,31 @@
 
     public String checkRelationTypeName( IRelation relation, String defaultName ) {
-	return null;
+    return null;
     }
 
     public String checkFormat( INode node, String defaultName ) {
-	return null;
+    return null;
     }
 
     public String checkFormat( IWay way, String defaultName ) {
-	if( way.get("place") != null && way.get("name") == null && way.get("place_name") != null )
-	    return way.get("place_name") + " " + defaultName;
-	return null;
+    if( way.get("place") != null && way.get("name") == null && way.get("place_name") != null )
+        return way.get("place_name") + " " + defaultName;
+    return null;
     }
 
     public String checkFormat( IRelation relation, String defaultName ) {
-	String type = relation.get("type");
-	if( type != null ) {
-	    String name = relation.get("destination");
-	    if( type.equals("destination_sign") && name != null ) {
-		if( relation.get("distance") != null )
-		    name += " " + relation.get("distance");
-		if( defaultName.indexOf('"') < 0 )
-		    return '"' + name + "\" " + defaultName;
-		else
-		    return defaultName.replaceFirst("\".?+\"", '"'+name+'"');
-	    }
-	}
-	return null;
+    String type = relation.get("type");
+    if( type != null ) {
+        String name = relation.get("destination");
+        if( type.equals("destination_sign") && name != null ) {
+        if( relation.get("distance") != null )
+            name += " " + relation.get("distance");
+        if( defaultName.indexOf('"') < 0 )
+            return '"' + name + "\" " + defaultName;
+        else
+            return defaultName.replaceFirst("\".?+\"", '"'+name+'"');
+        }
+    }
+    return null;
     }
 }
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/RelContextDialog.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/RelContextDialog.java	(revision 30737)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/RelContextDialog.java	(revision 30738)
@@ -97,5 +97,5 @@
 /**
  * The new, advanced relation editing panel.
- * 
+ *
  * @author Zverik
  */
@@ -103,5 +103,5 @@
 
     public final static String PREF_PREFIX = "reltoolbox";
-    
+
     private final DefaultTableModel relationsData;
     private ChosenRelation chosenRelation;
@@ -142,4 +142,5 @@
         roleBox.addMouseListener(relationMouseAdapter);
         roleBox.addItemListener(new ItemListener() {
+            @Override
             public void itemStateChanged( ItemEvent e ) {
                 if( e.getStateChange() == ItemEvent.DESELECTED ) return;
@@ -174,4 +175,5 @@
 
         roleBox.addPropertyChangeListener("enabled", new PropertyChangeListener() {
+            @Override
             public void propertyChange( PropertyChangeEvent evt ) {
                 boolean showRoleBox = roleBox.isEnabled();
@@ -182,4 +184,5 @@
 
         sortAndFixAction.addPropertyChangeListener(new PropertyChangeListener() {
+            @Override
             public void propertyChange( PropertyChangeEvent evt ) {
                 sortAndFixButton.setVisible(sortAndFixAction.isEnabled());
@@ -189,4 +192,5 @@
 
         downloadChosenRelationAction.addPropertyChangeListener(new PropertyChangeListener() {
+            @Override
             public void propertyChange( PropertyChangeEvent evt ) {
                 downloadButton.setVisible(downloadChosenRelationAction.isEnabled());
@@ -304,4 +308,5 @@
         columns.getColumn(0).setPreferredWidth(220);
         relationsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
+            @Override
             public void valueChanged( ListSelectionEvent e ) {
                 int selectedRow = relationsTable.getSelectedRow();
@@ -339,4 +344,5 @@
     }
 
+    @Override
     public void chosenRelationChanged( Relation oldRelation, Relation newRelation ) {
         if( chosenRelationPanel != null && Main.pref.getBoolean(PREF_PREFIX + ".hidetopline", false) )
@@ -348,4 +354,5 @@
     }
 
+    @Override
     public void selectionChanged( Collection<? extends OsmPrimitive> newSelection ) {
         if( !isVisible() || relationsData == null )
@@ -397,4 +404,5 @@
     }
 
+    @Override
     public void editLayerChanged( OsmDataLayer oldLayer, OsmDataLayer newLayer ) {
         updateSelection();
@@ -410,5 +418,5 @@
         super.destroy();
     }
-    
+
     private static final String POSSIBLE_ROLES_FILE = "relcontext/possible_roles.txt";
     private static final Map<String, List<String>> possibleRoles = loadRoles();
@@ -416,8 +424,9 @@
     private static Map<String, List<String>> loadRoles() {
         Map<String, List<String>> result = new HashMap<>();
-        try {
-            ClassLoader classLoader = RelContextDialog.class.getClassLoader();
-            final InputStream possibleRolesStream = classLoader.getResourceAsStream(POSSIBLE_ROLES_FILE);
+        ClassLoader classLoader = RelContextDialog.class.getClassLoader();
+        try (
+            InputStream possibleRolesStream = classLoader.getResourceAsStream(POSSIBLE_ROLES_FILE);
             BufferedReader r = new BufferedReader(new InputStreamReader(possibleRolesStream));
+        ) {
             while( r.ready() ) {
                 String line = r.readLine();
@@ -431,8 +440,7 @@
                 }
             }
-            r.close();
         } catch( Exception e ) {
-            System.err.println("[RelToolbox] Error reading possible roles file.");
-            e.printStackTrace();
+            Main.error("[RelToolbox] Error reading possible roles file.");
+            Main.error(e);
         }
         return result;
@@ -466,4 +474,5 @@
 
         role.getEditor().addActionListener(new ActionListener() {
+            @Override
             public void actionPerformed( ActionEvent e ) {
                 dlg.setVisible(false);
@@ -589,4 +598,5 @@
         }
 
+        @Override
         public void actionPerformed( ActionEvent e ) {
             String property = e.getActionCommand();
@@ -609,4 +619,5 @@
         }
 
+        @Override
         public void actionPerformed( ActionEvent e ) {
             if( roleBoxModel.membersRole != null ) {
@@ -617,9 +628,10 @@
         }
 
+        @Override
         public void chosenRelationChanged( Relation oldRelation, Relation newRelation ) {
             setEnabled(newRelation != null);
         }
     }
-        
+
     private class RoleComboBoxModel extends AbstractListModel<String> implements ComboBoxModel<String> {
         private List<String> roles = new ArrayList<>();
@@ -704,8 +716,10 @@
         }
 
+        @Override
         public int getSize() {
             return roles.size();
         }
 
+        @Override
         public String getElementAt( int index ) {
             return getRole(index);
@@ -716,4 +730,5 @@
         }
 
+        @Override
         public void setSelectedItem( Object anItem ) {
             int newIndex = anItem == null ? -1 : roles.indexOf(anItem);
@@ -724,4 +739,5 @@
         }
 
+        @Override
         public Object getSelectedItem() {
             return selectedIndex < 0 || selectedIndex >= getSize() ? null : getRole(selectedIndex);
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/RelContextPlugin.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/RelContextPlugin.java	(revision 30737)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/RelContextPlugin.java	(revision 30738)
@@ -11,5 +11,5 @@
     public RelContextPlugin( PluginInformation info ) {
         super(info);
-	DefaultNameFormatter.registerFormatHook(new ExtraNameFormatHook());
+    DefaultNameFormatter.registerFormatHook(new ExtraNameFormatHook());
     }
 
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/CreateMultipolygonAction.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/CreateMultipolygonAction.java	(revision 30737)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/CreateMultipolygonAction.java	(revision 30738)
@@ -28,127 +28,127 @@
 
     public CreateMultipolygonAction( ChosenRelation chRel ) {
-	super("Multi", "data/multipolygon", tr("Create a multipolygon from selected objects"),
-		Shortcut.registerShortcut("reltoolbox:multipolygon", tr("Relation Toolbox: {0}", tr("Create multipolygon")),
-		KeyEvent.VK_A, Shortcut.ALT_CTRL), false);
-	this.chRel = chRel;
-	updateEnabledState();
+    super("Multi", "data/multipolygon", tr("Create a multipolygon from selected objects"),
+        Shortcut.registerShortcut("reltoolbox:multipolygon", tr("Relation Toolbox: {0}", tr("Create multipolygon")),
+        KeyEvent.VK_A, Shortcut.ALT_CTRL), false);
+    this.chRel = chRel;
+    updateEnabledState();
     }
 
     public CreateMultipolygonAction() {
-	this(null);
+    this(null);
     }
 
     public static boolean getDefaultPropertyValue( String property ) {
-	if( property.equals("boundary") )
-	    return false;
-	else if( property.equals("boundaryways") )
-	    return true;
-	else if( property.equals("tags") )
-	    return true;
-	else if( property.equals("alltags") )
-	    return false;
-	else if( property.equals("single") )
-	    return true;
-	else if( property.equals("allowsplit") )
-	    return false;
-	throw new IllegalArgumentException(property);
+    if( property.equals("boundary") )
+        return false;
+    else if( property.equals("boundaryways") )
+        return true;
+    else if( property.equals("tags") )
+        return true;
+    else if( property.equals("alltags") )
+        return false;
+    else if( property.equals("single") )
+        return true;
+    else if( property.equals("allowsplit") )
+        return false;
+    throw new IllegalArgumentException(property);
     }
 
     private boolean getPref( String property ) {
-	return Main.pref.getBoolean(PREF_MULTIPOLY + property, getDefaultPropertyValue(property));
+    return Main.pref.getBoolean(PREF_MULTIPOLY + property, getDefaultPropertyValue(property));
     }
 
     public void actionPerformed( ActionEvent e ) {
-	boolean isBoundary = getPref("boundary");
-	Collection<Way> selectedWays = getCurrentDataSet().getSelectedWays();
-	if( !isBoundary && getPref("tags") ) {
-	    List<Relation> rels = null;
-	    if( getPref("allowsplit") || selectedWays.size() == 1 ) {
-		if( SplittingMultipolygons.canProcess(selectedWays) )
-		    rels = SplittingMultipolygons.process(getCurrentDataSet().getSelectedWays());
-	    } else {
-		if( TheRing.areAllOfThoseRings(selectedWays) ) {
-		    List<Command> commands = new ArrayList<>();
-		    rels = TheRing.makeManySimpleMultipolygons(getCurrentDataSet().getSelectedWays(), commands);
-		    if( !commands.isEmpty() )
-			Main.main.undoRedo.add(new SequenceCommand(tr("Create multipolygons from rings"), commands));
-		}
-	    }
-	    if( rels != null && !rels.isEmpty() ) {
-		if( chRel != null )
-		    chRel.set(rels.size() == 1 ? rels.get(0) : null);
-		if( rels.size() == 1 )
-		    getCurrentDataSet().setSelected(rels);
-		else
-		    getCurrentDataSet().clearSelection();
-		return;
-	    }
-	}
-
-	// for now, just copying standard action
-	MultipolygonBuilder mpc = new MultipolygonBuilder();
-	String error = mpc.makeFromWays(getCurrentDataSet().getSelectedWays());
-	if( error != null ) {
-	    JOptionPane.showMessageDialog(Main.parent, error);
-	    return;
-	}
-	Relation rel = new Relation();
-	if( isBoundary ) {
-	    rel.put("type", "boundary");
-	    rel.put("boundary", "administrative");
-	} else
-	    rel.put("type", "multipolygon");
-	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 )
-		rel.addMember(new RelationMember("inner", w));
-	List<Command> list = removeTagsFromInnerWays(rel);
-	if( !list.isEmpty() && isBoundary ) {
-	    Main.main.undoRedo.add(new SequenceCommand(tr("Move tags from ways to relation"), list));
-	    list = new ArrayList<>();
-	}
-	if( isBoundary ) {
-	    if( !askForAdminLevelAndName(rel) )
-		return;
-	    addBoundaryMembers(rel);
-	    if( getPref("boundaryways") )
-		list.addAll(fixWayTagsForBoundary(rel));
-	}
-	list.add(new AddCommand(rel));
-	Main.main.undoRedo.add(new SequenceCommand(tr("Create multipolygon"), list));
-
-	if( chRel != null )
-	    chRel.set(rel);
-
-	getCurrentDataSet().setSelected(rel);
+    boolean isBoundary = getPref("boundary");
+    Collection<Way> selectedWays = getCurrentDataSet().getSelectedWays();
+    if( !isBoundary && getPref("tags") ) {
+        List<Relation> rels = null;
+        if( getPref("allowsplit") || selectedWays.size() == 1 ) {
+        if( SplittingMultipolygons.canProcess(selectedWays) )
+            rels = SplittingMultipolygons.process(getCurrentDataSet().getSelectedWays());
+        } else {
+        if( TheRing.areAllOfThoseRings(selectedWays) ) {
+            List<Command> commands = new ArrayList<>();
+            rels = TheRing.makeManySimpleMultipolygons(getCurrentDataSet().getSelectedWays(), commands);
+            if( !commands.isEmpty() )
+            Main.main.undoRedo.add(new SequenceCommand(tr("Create multipolygons from rings"), commands));
+        }
+        }
+        if( rels != null && !rels.isEmpty() ) {
+        if( chRel != null )
+            chRel.set(rels.size() == 1 ? rels.get(0) : null);
+        if( rels.size() == 1 )
+            getCurrentDataSet().setSelected(rels);
+        else
+            getCurrentDataSet().clearSelection();
+        return;
+        }
+    }
+
+    // for now, just copying standard action
+    MultipolygonBuilder mpc = new MultipolygonBuilder();
+    String error = mpc.makeFromWays(getCurrentDataSet().getSelectedWays());
+    if( error != null ) {
+        JOptionPane.showMessageDialog(Main.parent, error);
+        return;
+    }
+    Relation rel = new Relation();
+    if( isBoundary ) {
+        rel.put("type", "boundary");
+        rel.put("boundary", "administrative");
+    } else
+        rel.put("type", "multipolygon");
+    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 )
+        rel.addMember(new RelationMember("inner", w));
+    List<Command> list = removeTagsFromInnerWays(rel);
+    if( !list.isEmpty() && isBoundary ) {
+        Main.main.undoRedo.add(new SequenceCommand(tr("Move tags from ways to relation"), list));
+        list = new ArrayList<>();
+    }
+    if( isBoundary ) {
+        if( !askForAdminLevelAndName(rel) )
+        return;
+        addBoundaryMembers(rel);
+        if( getPref("boundaryways") )
+        list.addAll(fixWayTagsForBoundary(rel));
+    }
+    list.add(new AddCommand(rel));
+    Main.main.undoRedo.add(new SequenceCommand(tr("Create multipolygon"), list));
+
+    if( chRel != null )
+        chRel.set(rel);
+
+    getCurrentDataSet().setSelected(rel);
     }
 
     @Override
     protected void updateEnabledState() {
-	if( getCurrentDataSet() == null ) {
-	    setEnabled(false);
-	} else {
-	    updateEnabledState(getCurrentDataSet().getSelected());
-	}
+    if( getCurrentDataSet() == null ) {
+        setEnabled(false);
+    } else {
+        updateEnabledState(getCurrentDataSet().getSelected());
+    }
     }
 
     @Override
     protected void updateEnabledState( Collection<? extends OsmPrimitive> selection ) {
-	boolean isEnabled = true;
-	if( selection == null || selection.isEmpty() )
-	    isEnabled = false;
-	else {
-	    if( !getPref("boundary") ) {
-		for( OsmPrimitive p : selection ) {
-		    if( !(p instanceof Way) ) {
-			isEnabled = false;
-			break;
-		    }
-		}
-	    }
-	}
-	setEnabled(isEnabled);
+    boolean isEnabled = true;
+    if( selection == null || selection.isEmpty() )
+        isEnabled = false;
+    else {
+        if( !getPref("boundary") ) {
+        for( OsmPrimitive p : selection ) {
+            if( !(p instanceof Way) ) {
+            isEnabled = false;
+            break;
+            }
+        }
+        }
+    }
+    setEnabled(isEnabled);
     }
 
@@ -157,20 +157,20 @@
      */
     private void addBoundaryMembers( Relation rel ) {
-	for( OsmPrimitive p : getCurrentDataSet().getSelected() ) {
-	    String role = null;
-	    if( p.getType().equals(OsmPrimitiveType.RELATION) ) {
-		role = "subarea";
-	    } else if( p.getType().equals(OsmPrimitiveType.NODE) ) {
-		Node n = (Node)p;
-		if( !n.isIncomplete() ) {
-		    if( n.hasKey("place") )
-			role = "admin_centre";
-		    else
-			role = "label";
-		}
-	    }
-	    if( role != null )
-		rel.addMember(new RelationMember(role, p));
-	}
+    for( OsmPrimitive p : getCurrentDataSet().getSelected() ) {
+        String role = null;
+        if( p.getType().equals(OsmPrimitiveType.RELATION) ) {
+        role = "subarea";
+        } else if( p.getType().equals(OsmPrimitiveType.NODE) ) {
+        Node n = (Node)p;
+        if( !n.isIncomplete() ) {
+            if( n.hasKey("place") )
+            role = "admin_centre";
+            else
+            role = "label";
+        }
+        }
+        if( role != null )
+        rel.addMember(new RelationMember(role, p));
+    }
     }
 
@@ -179,50 +179,50 @@
      */
     private List<Command> fixWayTagsForBoundary( Relation rel ) {
-	List<Command> commands = new ArrayList<>();
-	if( !rel.hasKey("boundary") || !rel.hasKey("admin_level") )
-	    return commands;
-	String adminLevelStr = rel.get("admin_level");
-	int adminLevel = 0;
-	try {
-	    adminLevel = Integer.parseInt(adminLevelStr);
-	} catch( NumberFormatException e ) {
-	    return commands;
-	}
-	Set<OsmPrimitive> waysBoundary = new HashSet<>();
-	Set<OsmPrimitive> waysAdminLevel = new HashSet<>();
-	for( OsmPrimitive p : rel.getMemberPrimitives() ) {
-	    if( p instanceof Way ) {
-		int count = 0;
-		if( p.hasKey("boundary") && p.get("boundary").equals("administrative") )
-		    count++;
-		if( p.hasKey("admin_level") )
-		    count++;
-		if( p.keySet().size() - count == 0 ) {
-		    if( !p.hasKey("boundary") )
-			waysBoundary.add(p);
-		    if( !p.hasKey("admin_level") ) {
-			waysAdminLevel.add(p);
-		    } else {
-			try {
-			    int oldAdminLevel = Integer.parseInt(p.get("admin_level"));
-			    if( oldAdminLevel > adminLevel )
-				waysAdminLevel.add(p);
-			} catch( NumberFormatException e ) {
-			    waysAdminLevel.add(p); // some garbage, replace it
-			}
-		    }
-		}
-	    }
-	}
-	if( !waysBoundary.isEmpty() )
-	    commands.add(new ChangePropertyCommand(waysBoundary, "boundary", "administrative"));
-	if( !waysAdminLevel.isEmpty() )
-	    commands.add(new ChangePropertyCommand(waysAdminLevel, "admin_level", adminLevelStr));
-	return commands;
+    List<Command> commands = new ArrayList<>();
+    if( !rel.hasKey("boundary") || !rel.hasKey("admin_level") )
+        return commands;
+    String adminLevelStr = rel.get("admin_level");
+    int adminLevel = 0;
+    try {
+        adminLevel = Integer.parseInt(adminLevelStr);
+    } catch( NumberFormatException e ) {
+        return commands;
+    }
+    Set<OsmPrimitive> waysBoundary = new HashSet<>();
+    Set<OsmPrimitive> waysAdminLevel = new HashSet<>();
+    for( OsmPrimitive p : rel.getMemberPrimitives() ) {
+        if( p instanceof Way ) {
+        int count = 0;
+        if( p.hasKey("boundary") && p.get("boundary").equals("administrative") )
+            count++;
+        if( p.hasKey("admin_level") )
+            count++;
+        if( p.keySet().size() - count == 0 ) {
+            if( !p.hasKey("boundary") )
+            waysBoundary.add(p);
+            if( !p.hasKey("admin_level") ) {
+            waysAdminLevel.add(p);
+            } else {
+            try {
+                int oldAdminLevel = Integer.parseInt(p.get("admin_level"));
+                if( oldAdminLevel > adminLevel )
+                waysAdminLevel.add(p);
+            } catch( NumberFormatException e ) {
+                waysAdminLevel.add(p); // some garbage, replace it
+            }
+            }
+        }
+        }
+    }
+    if( !waysBoundary.isEmpty() )
+        commands.add(new ChangePropertyCommand(waysBoundary, "boundary", "administrative"));
+    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"});
     private static final Set<String> REMOVE_FROM_BOUNDARY_TAGS = new TreeSet<>(Arrays.asList(new String[] {
-		"boundary", "boundary_type", "type", "admin_level"
-	    }));
+        "boundary", "boundary_type", "type", "admin_level"
+        }));
 
     /**
@@ -232,112 +232,112 @@
      */
     private List<Command> removeTagsFromInnerWays( Relation relation ) {
-	Map<String, String> values = new HashMap<>();
-
-	if( relation.hasKeys() ) {
-	    for( String key : relation.keySet() ) {
-		values.put(key, relation.get(key));
-	    }
-	}
-
-	List<Way> innerWays = new ArrayList<>();
-	List<Way> outerWays = new ArrayList<>();
-
-	Set<String> conflictingKeys = new TreeSet<>();
-
-	for( RelationMember m : relation.getMembers() ) {
-
-	    if( m.hasRole() && "inner".equals(m.getRole()) && m.isWay() && m.getWay().hasKeys() ) {
-		innerWays.add(m.getWay());
-	    }
-
-	    if( m.hasRole() && "outer".equals(m.getRole()) && m.isWay() && m.getWay().hasKeys() ) {
-		Way way = m.getWay();
-		outerWays.add(way);
-		for( String key : way.keySet() ) {
-		    if( !values.containsKey(key) ) { //relation values take precedence
-			values.put(key, way.get(key));
-		    } else if( !relation.hasKey(key) && !values.get(key).equals(way.get(key)) ) {
-			conflictingKeys.add(key);
-		    }
-		}
-	    }
-	}
-
-	// 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) )
-			    conflictingKeys.add(key);
-
-	for( String key : conflictingKeys )
-	    values.remove(key);
-
-	for( String linearTag : Main.pref.getCollection(PREF_MULTIPOLY + "lineartags", DEFAULT_LINEAR_TAGS) )
-	    values.remove(linearTag);
-
-	if( values.containsKey("natural") && values.get("natural").equals("coastline") )
-	    values.remove("natural");
-
-	String name = values.get("name");
-	if( isBoundary ) {
-	    Set<String> keySet = new TreeSet<>(values.keySet());
-	    for( String key : keySet )
-		if( !REMOVE_FROM_BOUNDARY_TAGS.contains(key) )
-		    values.remove(key);
-	}
-
-	values.put("area", "yes");
-
-	List<Command> commands = new ArrayList<>();
-	boolean moveTags = getPref("tags");
-
-	for( String key : values.keySet() ) {
-	    List<OsmPrimitive> affectedWays = new ArrayList<>();
-	    String value = values.get(key);
-
-	    for( Way way : innerWays ) {
-		if( way.hasKey(key) && (isBoundary || value.equals(way.get(key))) ) {
-		    affectedWays.add(way);
-		}
-	    }
-
-	    if( moveTags ) {
-		// remove duplicated tags from outer ways
-		for( Way way : outerWays ) {
-		    if( way.hasKey(key) ) {
-			affectedWays.add(way);
-		    }
-		}
-	    }
-
-	    if( affectedWays.size() > 0 ) {
-		commands.add(new ChangePropertyCommand(affectedWays, key, null));
-	    }
-	}
-
-	if( moveTags ) {
-	    // add those tag values to the relation
-	    if( isBoundary )
-		values.put("name", name);
-	    boolean fixed = false;
-	    Relation r2 = new Relation(relation);
-	    for( String key : values.keySet() ) {
-		if( !r2.hasKey(key) && !key.equals("area")
-			&& (!isBoundary || key.equals("admin_level") || key.equals("name")) ) {
-		    if( relation.isNew() )
-			relation.put(key, values.get(key));
-		    else
-			r2.put(key, values.get(key));
-		    fixed = true;
-		}
-	    }
-	    if( fixed && !relation.isNew() )
-		commands.add(new ChangeCommand(relation, r2));
-	}
-
-	return commands;
+    Map<String, String> values = new HashMap<>();
+
+    if( relation.hasKeys() ) {
+        for( String key : relation.keySet() ) {
+        values.put(key, relation.get(key));
+        }
+    }
+
+    List<Way> innerWays = new ArrayList<>();
+    List<Way> outerWays = new ArrayList<>();
+
+    Set<String> conflictingKeys = new TreeSet<>();
+
+    for( RelationMember m : relation.getMembers() ) {
+
+        if( m.hasRole() && "inner".equals(m.getRole()) && m.isWay() && m.getWay().hasKeys() ) {
+        innerWays.add(m.getWay());
+        }
+
+        if( m.hasRole() && "outer".equals(m.getRole()) && m.isWay() && m.getWay().hasKeys() ) {
+        Way way = m.getWay();
+        outerWays.add(way);
+        for( String key : way.keySet() ) {
+            if( !values.containsKey(key) ) { //relation values take precedence
+            values.put(key, way.get(key));
+            } else if( !relation.hasKey(key) && !values.get(key).equals(way.get(key)) ) {
+            conflictingKeys.add(key);
+            }
+        }
+        }
+    }
+
+    // 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) )
+                conflictingKeys.add(key);
+
+    for( String key : conflictingKeys )
+        values.remove(key);
+
+    for( String linearTag : Main.pref.getCollection(PREF_MULTIPOLY + "lineartags", DEFAULT_LINEAR_TAGS) )
+        values.remove(linearTag);
+
+    if( values.containsKey("natural") && values.get("natural").equals("coastline") )
+        values.remove("natural");
+
+    String name = values.get("name");
+    if( isBoundary ) {
+        Set<String> keySet = new TreeSet<>(values.keySet());
+        for( String key : keySet )
+        if( !REMOVE_FROM_BOUNDARY_TAGS.contains(key) )
+            values.remove(key);
+    }
+
+    values.put("area", "yes");
+
+    List<Command> commands = new ArrayList<>();
+    boolean moveTags = getPref("tags");
+
+    for( String key : values.keySet() ) {
+        List<OsmPrimitive> affectedWays = new ArrayList<>();
+        String value = values.get(key);
+
+        for( Way way : innerWays ) {
+        if( way.hasKey(key) && (isBoundary || value.equals(way.get(key))) ) {
+            affectedWays.add(way);
+        }
+        }
+
+        if( moveTags ) {
+        // remove duplicated tags from outer ways
+        for( Way way : outerWays ) {
+            if( way.hasKey(key) ) {
+            affectedWays.add(way);
+            }
+        }
+        }
+
+        if( affectedWays.size() > 0 ) {
+        commands.add(new ChangePropertyCommand(affectedWays, key, null));
+        }
+    }
+
+    if( moveTags ) {
+        // add those tag values to the relation
+        if( isBoundary )
+        values.put("name", name);
+        boolean fixed = false;
+        Relation r2 = new Relation(relation);
+        for( String key : values.keySet() ) {
+        if( !r2.hasKey(key) && !key.equals("area")
+            && (!isBoundary || key.equals("admin_level") || key.equals("name")) ) {
+            if( relation.isNew() )
+            relation.put(key, values.get(key));
+            else
+            r2.put(key, values.get(key));
+            fixed = true;
+        }
+        }
+        if( fixed && !relation.isNew() )
+        commands.add(new ChangeCommand(relation, r2));
+    }
+
+    return commands;
     }
 
@@ -348,59 +348,59 @@
      */
     private boolean askForAdminLevelAndName( Relation rel ) {
-	String relAL = rel.get("admin_level");
-	String relName = rel.get("name");
-	if( relAL != null && relName != null )
-	    return true;
-
-	JPanel panel = new JPanel(new GridBagLayout());
-	panel.add(new JLabel(tr("Enter admin level and name for the border relation:")), GBC.eol().insets(0, 0, 0, 5));
-
-	final JTextField admin = new JTextField();
-	admin.setText(relAL != null ? relAL : Main.pref.get(PREF_MULTIPOLY + "lastadmin", ""));
-	panel.add(new JLabel(tr("Admin level")), GBC.std());
-	panel.add(Box.createHorizontalStrut(10), GBC.std());
-	panel.add(admin, GBC.eol().fill(GBC.HORIZONTAL).insets(0, 0, 0, 5));
-
-	final JTextField name = new JTextField();
-	if( relName != null )
-	    name.setText(relName);
-	panel.add(new JLabel(tr("Name")), GBC.std());
-	panel.add(Box.createHorizontalStrut(10), GBC.std());
-	panel.add(name, GBC.eol().fill(GBC.HORIZONTAL));
-
-	final JOptionPane optionPane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION) {
-	    @Override
-	    public void selectInitialValue() {
-		admin.requestFocusInWindow();
-		admin.selectAll();
-	    }
-	};
-	final JDialog dlg = optionPane.createDialog(Main.parent, tr("Create a new relation"));
-	dlg.setModalityType(ModalityType.DOCUMENT_MODAL);
-
-	name.addActionListener(new ActionListener() {
-	    public void actionPerformed( ActionEvent e ) {
-		dlg.setVisible(false);
-		optionPane.setValue(JOptionPane.OK_OPTION);
-	    }
-	});
-
-	dlg.setVisible(true);
-
-	Object answer = optionPane.getValue();
-	if( answer == null || answer == JOptionPane.UNINITIALIZED_VALUE
-		|| (answer instanceof Integer && (Integer)answer != JOptionPane.OK_OPTION) ) {
-	    return false;
-	}
-
-	String admin_level = admin.getText().trim();
-	String new_name = name.getText().trim();
-	if( admin_level.equals("10") || (admin_level.length() == 1 && Character.isDigit(admin_level.charAt(0))) ) {
-	    rel.put("admin_level", admin_level);
-	    Main.pref.put(PREF_MULTIPOLY + "lastadmin", admin_level);
-	}
-	if( new_name.length() > 0 )
-	    rel.put("name", new_name);
-	return true;
+    String relAL = rel.get("admin_level");
+    String relName = rel.get("name");
+    if( relAL != null && relName != null )
+        return true;
+
+    JPanel panel = new JPanel(new GridBagLayout());
+    panel.add(new JLabel(tr("Enter admin level and name for the border relation:")), GBC.eol().insets(0, 0, 0, 5));
+
+    final JTextField admin = new JTextField();
+    admin.setText(relAL != null ? relAL : Main.pref.get(PREF_MULTIPOLY + "lastadmin", ""));
+    panel.add(new JLabel(tr("Admin level")), GBC.std());
+    panel.add(Box.createHorizontalStrut(10), GBC.std());
+    panel.add(admin, GBC.eol().fill(GBC.HORIZONTAL).insets(0, 0, 0, 5));
+
+    final JTextField name = new JTextField();
+    if( relName != null )
+        name.setText(relName);
+    panel.add(new JLabel(tr("Name")), GBC.std());
+    panel.add(Box.createHorizontalStrut(10), GBC.std());
+    panel.add(name, GBC.eol().fill(GBC.HORIZONTAL));
+
+    final JOptionPane optionPane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION) {
+        @Override
+        public void selectInitialValue() {
+        admin.requestFocusInWindow();
+        admin.selectAll();
+        }
+    };
+    final JDialog dlg = optionPane.createDialog(Main.parent, tr("Create a new relation"));
+    dlg.setModalityType(ModalityType.DOCUMENT_MODAL);
+
+    name.addActionListener(new ActionListener() {
+        public void actionPerformed( ActionEvent e ) {
+        dlg.setVisible(false);
+        optionPane.setValue(JOptionPane.OK_OPTION);
+        }
+    });
+
+    dlg.setVisible(true);
+
+    Object answer = optionPane.getValue();
+    if( answer == null || answer == JOptionPane.UNINITIALIZED_VALUE
+        || (answer instanceof Integer && (Integer)answer != JOptionPane.OK_OPTION) ) {
+        return false;
+    }
+
+    String admin_level = admin.getText().trim();
+    String new_name = name.getText().trim();
+    if( admin_level.equals("10") || (admin_level.length() == 1 && Character.isDigit(admin_level.charAt(0))) ) {
+        rel.put("admin_level", admin_level);
+        Main.pref.put(PREF_MULTIPOLY + "lastadmin", admin_level);
+    }
+    if( new_name.length() > 0 )
+        rel.put("name", new_name);
+    return true;
     }
 }
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ReconstructPolygonAction.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ReconstructPolygonAction.java	(revision 30737)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ReconstructPolygonAction.java	(revision 30738)
@@ -42,10 +42,10 @@
     
     private static final List<String> IRRELEVANT_KEYS = Arrays.asList(new String[] {
-	"source", "created_by", "note"});
+    "source", "created_by", "note"});
 
     public ReconstructPolygonAction( ChosenRelation rel ) {
         super(tr("Reconstruct polygon"));
         putValue(SMALL_ICON, ImageProvider.get("dialogs", "filter"));
-	putValue(LONG_DESCRIPTION, "Reconstruct polygon from multipolygon relation");
+    putValue(LONG_DESCRIPTION, "Reconstruct polygon from multipolygon relation");
         this.rel = rel;
         rel.addChosenRelationListener(this);
@@ -55,110 +55,110 @@
     public void actionPerformed( ActionEvent e ) {
         Relation r = rel.get();
-	List<Way> ways = new ArrayList<>();
-	boolean wont = false;
-	for( RelationMember m : r.getMembers() ) {
-	    if( m.isWay() )
-		ways.add(m.getWay());
-	    else
-		wont = true;
-	}
-	if( wont ) {
-	    JOptionPane.showMessageDialog(Main.parent, tr("Multipolygon must consist only of ways"), tr("Reconstruct polygon"), JOptionPane.ERROR_MESSAGE);
-	    return;
-	}
-	
-	MultipolygonBuilder mpc = new MultipolygonBuilder();
-	String error = mpc.makeFromWays(ways);
-	if( error != null ) {
-	    JOptionPane.showMessageDialog(Main.parent, error);
-	    return;
-	}
-	
-	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);
-	    return;
-	}
-	
-	rel.clear();
-	List<Way> newSelection = new ArrayList<>();
-	List<Command> commands = new ArrayList<>();
+    List<Way> ways = new ArrayList<>();
+    boolean wont = false;
+    for( RelationMember m : r.getMembers() ) {
+        if( m.isWay() )
+        ways.add(m.getWay());
+        else
+        wont = true;
+    }
+    if( wont ) {
+        JOptionPane.showMessageDialog(Main.parent, tr("Multipolygon must consist only of ways"), tr("Reconstruct polygon"), JOptionPane.ERROR_MESSAGE);
+        return;
+    }
+    
+    MultipolygonBuilder mpc = new MultipolygonBuilder();
+    String error = mpc.makeFromWays(ways);
+    if( error != null ) {
+        JOptionPane.showMessageDialog(Main.parent, error);
+        return;
+    }
+    
+    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);
+        return;
+    }
+    
+    rel.clear();
+    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 )
             return;
-	commands.add(c);
-	
-	for( JoinedPolygon p : mpc.outerWays ) {
-	    // move all tags from relation and common tags from ways
-	    Map<String, String> tags = p.ways.get(0).getKeys();
-	    List<OsmPrimitive> relations = p.ways.get(0).getReferrers();
-	    Set<String> noTags = new HashSet<>(r.keySet());
-	    for( int i = 1; i < p.ways.size(); i++ ) {
-		Way w = p.ways.get(i);
-		for( String key : w.keySet() ) {
-		    String value = w.get(key);
-		    if( !noTags.contains(key) && tags.containsKey(key) && !tags.get(key).equals(value) ) {
-			tags.remove(key);
-			noTags.add(key);
-		    }
-		}
-		List<OsmPrimitive> referrers = w.getReferrers();
-		for( Iterator<OsmPrimitive> ref1 = relations.iterator(); ref1.hasNext(); )
-		    if( !referrers.contains(ref1.next()) )
-			ref1.remove();
-	    }
-	    tags.putAll(r.getKeys());
-	    tags.remove("type");
-	    
-	    // then delete ways that are not relevant (do not take part in other relations of have strange tags)
-	    Way candidateWay = null;
-	    for( Way w : p.ways ) {
-		if( w.getReferrers().equals(relations) ) {
-		    // check tags that remain
-		    Set<String> keys = new HashSet<>(w.keySet());
-		    keys.removeAll(tags.keySet());
-		    keys.removeAll(IRRELEVANT_KEYS);
-		    if( keys.isEmpty() ) {
-			if( candidateWay == null )
-			    candidateWay = w;
-			else {
-			    if( candidateWay.isNew() && !w.isNew() ) {
-				// prefer ways that are already in the database
-				Way tmp = w;
-				w = candidateWay;
-				candidateWay = tmp;
-			    }
-			    commands.add(new DeleteCommand(w));
-			}
-		    }
-		}
-	    }
-	    
-	    // take the first way, put all nodes into it, making it a closed polygon
-	    Way result = candidateWay == null ? new Way() : new Way(candidateWay);
-	    result.setNodes(p.nodes);
-	    result.addNode(result.firstNode());
-	    result.setKeys(tags);
-	    newSelection.add(candidateWay == null ? result : candidateWay);
-	    commands.add(candidateWay == null ? new AddCommand(result) : new ChangeCommand(candidateWay, result));
-	}
-	
+    commands.add(c);
+    
+    for( JoinedPolygon p : mpc.outerWays ) {
+        // move all tags from relation and common tags from ways
+        Map<String, String> tags = p.ways.get(0).getKeys();
+        List<OsmPrimitive> relations = p.ways.get(0).getReferrers();
+        Set<String> noTags = new HashSet<>(r.keySet());
+        for( int i = 1; i < p.ways.size(); i++ ) {
+        Way w = p.ways.get(i);
+        for( String key : w.keySet() ) {
+            String value = w.get(key);
+            if( !noTags.contains(key) && tags.containsKey(key) && !tags.get(key).equals(value) ) {
+            tags.remove(key);
+            noTags.add(key);
+            }
+        }
+        List<OsmPrimitive> referrers = w.getReferrers();
+        for( Iterator<OsmPrimitive> ref1 = relations.iterator(); ref1.hasNext(); )
+            if( !referrers.contains(ref1.next()) )
+            ref1.remove();
+        }
+        tags.putAll(r.getKeys());
+        tags.remove("type");
+        
+        // then delete ways that are not relevant (do not take part in other relations of have strange tags)
+        Way candidateWay = null;
+        for( Way w : p.ways ) {
+        if( w.getReferrers().equals(relations) ) {
+            // check tags that remain
+            Set<String> keys = new HashSet<>(w.keySet());
+            keys.removeAll(tags.keySet());
+            keys.removeAll(IRRELEVANT_KEYS);
+            if( keys.isEmpty() ) {
+            if( candidateWay == null )
+                candidateWay = w;
+            else {
+                if( candidateWay.isNew() && !w.isNew() ) {
+                // prefer ways that are already in the database
+                Way tmp = w;
+                w = candidateWay;
+                candidateWay = tmp;
+                }
+                commands.add(new DeleteCommand(w));
+            }
+            }
+        }
+        }
+        
+        // take the first way, put all nodes into it, making it a closed polygon
+        Way result = candidateWay == null ? new Way() : new Way(candidateWay);
+        result.setNodes(p.nodes);
+        result.addNode(result.firstNode());
+        result.setKeys(tags);
+        newSelection.add(candidateWay == null ? result : candidateWay);
+        commands.add(candidateWay == null ? new AddCommand(result) : new ChangeCommand(candidateWay, result));
+    }
+    
         Main.main.undoRedo.add(new SequenceCommand(tr("Reconstruct polygons from relation {0}",
-		r.getDisplayName(DefaultNameFormatter.getInstance())), commands));
-	Main.main.getCurrentDataSet().setSelected(newSelection);
+        r.getDisplayName(DefaultNameFormatter.getInstance())), commands));
+    Main.main.getCurrentDataSet().setSelected(newSelection);
     }
 
     public void chosenRelationChanged( Relation oldRelation, Relation newRelation ) {
-	setEnabled(isSuitableRelation(newRelation));
+    setEnabled(isSuitableRelation(newRelation));
     }
     
     private boolean isSuitableRelation( Relation newRelation ) {
-	if( newRelation == null || !"multipolygon".equals(newRelation.get("type")) || newRelation.getMembersCount() == 0 )
-	    return false;
-	else {
-	    for( RelationMember m : newRelation.getMembers() )
-		if( "inner".equals(m.getRole()) )
-		    return false;
-	    return true;
-	}
+    if( newRelation == null || !"multipolygon".equals(newRelation.get("type")) || newRelation.getMembersCount() == 0 )
+        return false;
+    else {
+        for( RelationMember m : newRelation.getMembers() )
+        if( "inner".equals(m.getRole()) )
+            return false;
+        return true;
+    }
     }
 }
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SortAndFixAction.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SortAndFixAction.java	(revision 30737)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SortAndFixAction.java	(revision 30738)
@@ -25,6 +25,6 @@
 
 public class SortAndFixAction extends AbstractAction implements ChosenRelationListener {
-	private static final long serialVersionUID = 1L;
-	private ChosenRelation rel;
+    private static final long serialVersionUID = 1L;
+    private ChosenRelation rel;
     private List<RelationFixer> fixers;
 
@@ -67,8 +67,8 @@
 
     private RelationFixer getFixer( Relation rel ) {
-    	for(RelationFixer fixer : fixers)
-    		if (fixer.isFixerApplicable(rel))
-    			return fixer;
-    	return new NothingFixer();
+        for(RelationFixer fixer : fixers)
+            if (fixer.isFixerApplicable(rel))
+                return fixer;
+        return new NothingFixer();
     }
 
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SplittingMultipolygons.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SplittingMultipolygons.java	(revision 30737)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SplittingMultipolygons.java	(revision 30738)
@@ -24,78 +24,78 @@
 
     public static boolean canProcess( Collection<Way> ways ) {
-	List<Way> rings = new ArrayList<>();
-	List<Way> arcs = new ArrayList<>();
-	Area a = Main.main.getCurrentDataSet().getDataSourceArea();
-	for( Way way : ways ) {
-	    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())) )
-    		    return false;
-	    }
-	    if( way.isClosed() )
-		rings.add(way);
-	    else
-		arcs.add(way);
-	}
-	
-	// If there are more that one segment, check that they touch rings
-	if( arcs.size() > 1 ) {
-	    for( Way segment : arcs ) {
-		boolean found = false;
-		for( Way ring : rings )
-		    if( ring.containsNode(segment.firstNode()) && ring.containsNode(segment.lastNode()) )
-			found = true;
-		if( !found )
-		    return false;
-	    }
-	}
-
-	if( rings.isEmpty() && arcs.isEmpty() )
-	    return false;
-
-	// check for non-containment of rings
-	for( int i = 0; i < rings.size() - 1; i++ ) {
-	    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 )
-		    return false;
-	    }
-	}
-
-	return true;
+    List<Way> rings = new ArrayList<>();
+    List<Way> arcs = new ArrayList<>();
+    Area a = Main.main.getCurrentDataSet().getDataSourceArea();
+    for( Way way : ways ) {
+        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())) )
+                return false;
+        }
+        if( way.isClosed() )
+        rings.add(way);
+        else
+        arcs.add(way);
+    }
+    
+    // If there are more that one segment, check that they touch rings
+    if( arcs.size() > 1 ) {
+        for( Way segment : arcs ) {
+        boolean found = false;
+        for( Way ring : rings )
+            if( ring.containsNode(segment.firstNode()) && ring.containsNode(segment.lastNode()) )
+            found = true;
+        if( !found )
+            return false;
+        }
+    }
+
+    if( rings.isEmpty() && arcs.isEmpty() )
+        return false;
+
+    // check for non-containment of rings
+    for( int i = 0; i < rings.size() - 1; i++ ) {
+        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 )
+            return false;
+        }
+    }
+
+    return true;
     }
     
     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() )
-		rings.add(way);
-	    else
-		arcs.add(way);
-	}
-
-	for( Way ring : rings ) {
-	    List<Command> commands = new ArrayList<>();
-	    Relation newRelation = SplittingMultipolygons.attachRingToNeighbours(ring, commands);
-	    if( newRelation != null && !commands.isEmpty() ) {
-		Main.main.undoRedo.add(commands.get(0));
-		result.add(newRelation);
-	    }
-	}
-
-	for( Way arc : arcs) {
-	    List<Command> commands = new ArrayList<>();
-	    Relation newRelation = SplittingMultipolygons.tryToCloseOneWay(arc, commands);
-	    if( newRelation != null && !commands.isEmpty() ) {
-		Main.main.undoRedo.add(commands.get(0));
-		result.add(newRelation);
-	    }
-	}
-	return result;
+//    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() )
+        rings.add(way);
+        else
+        arcs.add(way);
+    }
+
+    for( Way ring : rings ) {
+        List<Command> commands = new ArrayList<>();
+        Relation newRelation = SplittingMultipolygons.attachRingToNeighbours(ring, commands);
+        if( newRelation != null && !commands.isEmpty() ) {
+        Main.main.undoRedo.add(commands.get(0));
+        result.add(newRelation);
+        }
+    }
+
+    for( Way arc : arcs) {
+        List<Command> commands = new ArrayList<>();
+        Relation newRelation = SplittingMultipolygons.tryToCloseOneWay(arc, commands);
+        if( newRelation != null && !commands.isEmpty() ) {
+        Main.main.undoRedo.add(commands.get(0));
+        result.add(newRelation);
+        }
+    }
+    return result;
     }
 
@@ -104,11 +104,11 @@
      */
     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<>(append);
-	    Collections.reverse(ap2);
-	    append = ap2;
-	}
-	base.remove(base.size() - 1);
-	base.addAll(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<>(append);
+        Collections.reverse(ap2);
+        append = ap2;
+    }
+    base.remove(base.size() - 1);
+    base.addAll(append);
     }
 
@@ -117,8 +117,8 @@
      */
     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);
+    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);
     }
 
@@ -131,92 +131,92 @@
      */
     public static List<Way> splitWay( Way w, Node n1, Node n2, List<Command> commands ) {
-	List<Node> nodes = new ArrayList<>(w.getNodes());
-	if( w.isClosed() )
-	    nodes.remove(nodes.size() - 1);
-	int index1 = nodes.indexOf(n1);
-	int index2 = n2 == null ? -1 : nodes.indexOf(n2);
-	if( index1 > index2 ) {
-	    int tmp = index1;
-	    index1 = index2;
-	    index2 = tmp;
-	}
-	// right now index2 >= index1
-	if( index2 < 1 || index1 >= w.getNodesCount() - 1 || index2 >= w.getNodesCount() )
-	    return Collections.emptyList();
-	if( w.isClosed() && (index1 < 0 || index1 == index2 || index1 + w.getNodesCount() == index2) )
-	    return Collections.emptyList();
-	
-	// todo: download parent relations!
-
-	// make a list of segments
-	List<List<Node>> chunks = new ArrayList<>(2);
-	List<Node> chunk = new ArrayList<>();
-	for( int i = 0; i < nodes.size(); i++ ) {
-	    chunk.add(nodes.get(i));
-	    if( (w.isClosed() || chunk.size() > 1) && (i == index1 || i == index2) ) {
-		chunks.add(chunk);
-		chunk = new ArrayList<>();
-		chunk.add(nodes.get(i));
-	    }
-	}
-	chunks.add(chunk);
-
-	// for closed way ignore the way boundary
-	if( w.isClosed() ) {
-	    chunks.get(chunks.size() - 1).addAll(chunks.get(0));
-	    chunks.remove(0);
-	} 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
-	Map<Relation, Integer> references = new HashMap<>();
-	List<Command> relationCommands = new ArrayList<>();
-	for( OsmPrimitive p : w.getReferrers() ) {
-	    if( p instanceof Relation ) {
-		Relation rel = commands == null ? (Relation)p : new Relation((Relation)p);
-		if( commands != null )
-		    relationCommands.add(new ChangeCommand((Relation)p, rel));
-		for( int i = 0; i < rel.getMembersCount(); i++ )
-		    if( rel.getMember(i).getMember().equals(w) )
-			references.put(rel, Integer.valueOf(i));
-	    }
-	}
-
-	// build ways
-	List<Way> result = new ArrayList<>();
-	Way updatedWay = commands == null ? w : new Way(w);
-	updatedWay.setNodes(chunks.get(0));
-	if( commands != null ) {
-	    commands.add(new ChangeCommand(w, updatedWay));
-	    result.add(updatedWay);
-	}
-
-	for( int i = 1; i < chunks.size(); i++ ) {
-	    List<Node> achunk = chunks.get(i);
-	    Way newWay = new Way();
-	    newWay.setKeys(w.getKeys());
-	    result.add(newWay);
-	    for( Relation rel : references.keySet() ) {
-		int relIndex = references.get(rel);
-		rel.addMember(relIndex + 1, new RelationMember(rel.getMember(relIndex).getRole(), newWay));
-	    }
-	    newWay.setNodes(achunk);
-	    if( commands != null )
-		commands.add(new AddCommand(newWay));
-	}
-	if( commands != null )
-	    commands.addAll(relationCommands);
-	return result;
+    List<Node> nodes = new ArrayList<>(w.getNodes());
+    if( w.isClosed() )
+        nodes.remove(nodes.size() - 1);
+    int index1 = nodes.indexOf(n1);
+    int index2 = n2 == null ? -1 : nodes.indexOf(n2);
+    if( index1 > index2 ) {
+        int tmp = index1;
+        index1 = index2;
+        index2 = tmp;
+    }
+    // right now index2 >= index1
+    if( index2 < 1 || index1 >= w.getNodesCount() - 1 || index2 >= w.getNodesCount() )
+        return Collections.emptyList();
+    if( w.isClosed() && (index1 < 0 || index1 == index2 || index1 + w.getNodesCount() == index2) )
+        return Collections.emptyList();
+    
+    // todo: download parent relations!
+
+    // make a list of segments
+    List<List<Node>> chunks = new ArrayList<>(2);
+    List<Node> chunk = new ArrayList<>();
+    for( int i = 0; i < nodes.size(); i++ ) {
+        chunk.add(nodes.get(i));
+        if( (w.isClosed() || chunk.size() > 1) && (i == index1 || i == index2) ) {
+        chunks.add(chunk);
+        chunk = new ArrayList<>();
+        chunk.add(nodes.get(i));
+        }
+    }
+    chunks.add(chunk);
+
+    // for closed way ignore the way boundary
+    if( w.isClosed() ) {
+        chunks.get(chunks.size() - 1).addAll(chunks.get(0));
+        chunks.remove(0);
+    } 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
+    Map<Relation, Integer> references = new HashMap<>();
+    List<Command> relationCommands = new ArrayList<>();
+    for( OsmPrimitive p : w.getReferrers() ) {
+        if( p instanceof Relation ) {
+        Relation rel = commands == null ? (Relation)p : new Relation((Relation)p);
+        if( commands != null )
+            relationCommands.add(new ChangeCommand((Relation)p, rel));
+        for( int i = 0; i < rel.getMembersCount(); i++ )
+            if( rel.getMember(i).getMember().equals(w) )
+            references.put(rel, Integer.valueOf(i));
+        }
+    }
+
+    // build ways
+    List<Way> result = new ArrayList<>();
+    Way updatedWay = commands == null ? w : new Way(w);
+    updatedWay.setNodes(chunks.get(0));
+    if( commands != null ) {
+        commands.add(new ChangeCommand(w, updatedWay));
+        result.add(updatedWay);
+    }
+
+    for( int i = 1; i < chunks.size(); i++ ) {
+        List<Node> achunk = chunks.get(i);
+        Way newWay = new Way();
+        newWay.setKeys(w.getKeys());
+        result.add(newWay);
+        for( Relation rel : references.keySet() ) {
+        int relIndex = references.get(rel);
+        rel.addMember(relIndex + 1, new RelationMember(rel.getMember(relIndex).getRole(), newWay));
+        }
+        newWay.setNodes(achunk);
+        if( commands != null )
+        commands.add(new AddCommand(newWay));
+    }
+    if( commands != null )
+        commands.addAll(relationCommands);
+    return result;
     }
 
     public static List<Way> splitWay( Way w, Node n1, Node n2 ) {
-	return splitWay(w, n1, n2, null);
+    return splitWay(w, n1, n2, null);
     }
 
@@ -225,65 +225,65 @@
      */
     public static Relation tryToCloseOneWay( Way segment, List<Command> resultingCommands ) {
-	if( segment.isClosed() || segment.isIncomplete() )
-	    return null;
-
-	List<Way> ways = intersection(
-		OsmPrimitive.getFilteredList(segment.firstNode().getReferrers(), Way.class),
-		OsmPrimitive.getFilteredList(segment.lastNode().getReferrers(), Way.class));
-	ways.remove(segment);
-	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() )
-		    save = true;
-	    if( !save )
-		iter.remove();
-	}
-	if( ways.isEmpty() )
-	    return null; // well...
-	Way target = ways.get(0);
-
-	// time to create a new multipolygon relation and a command stack
-	List<Command> commands = new ArrayList<>();
-	Relation newRelation = new Relation();
-	newRelation.put("type", "multipolygon");
-	newRelation.addMember(new RelationMember("outer", segment));
-	Collection<String> linearTags = Main.pref.getCollection(PREF_MULTIPOLY + "lineartags", CreateMultipolygonAction.DEFAULT_LINEAR_TAGS);
-	Way segmentCopy = new Way(segment);
-	boolean changed = false;
-	for( String key : segmentCopy.keySet() ) {
-	    if( !linearTags.contains(key) ) {
-		newRelation.put(key, segmentCopy.get(key));
-		segmentCopy.remove(key);
-		changed = true;
-	    }
-	}
-	if( changed )
-	    commands.add(new ChangeCommand(segment, segmentCopy));
-
-	// now split the way, at last
-	List<Way> newWays = new ArrayList<>(splitWay(target, segment.firstNode(), segment.lastNode(), commands));
-
-	Way addingWay = null;
-	if( target.isClosed() ) {
-	    Way utarget = newWays.get(1);
-	    Way alternate = newWays.get(0);
-	    List<Node> testRing = new ArrayList<>(segment.getNodes());
-	    closePolygon(testRing, utarget.getNodes());
-	    addingWay = segmentInsidePolygon(alternate.getNode(0), alternate.getNode(1), testRing) ? alternate : utarget;
-	} else {
-	    for( Way w : newWays ) {
-		if( (w.firstNode().equals(segment.firstNode()) && w.lastNode().equals(segment.lastNode()))
-			|| (w.firstNode().equals(segment.lastNode()) && w.lastNode().equals(segment.firstNode())) ) {
-		    addingWay = w;
-		    break;
-		}
-	    }
-	}
-	newRelation.addMember(new RelationMember("outer", addingWay.getUniqueId() == target.getUniqueId() ? target : addingWay));
-	commands.add(new AddCommand(newRelation));
-	resultingCommands.add(new SequenceCommand(tr("Complete multipolygon for way {0}",
-		DefaultNameFormatter.getInstance().format(segment)), commands));
-	return newRelation;
+    if( segment.isClosed() || segment.isIncomplete() )
+        return null;
+
+    List<Way> ways = intersection(
+        OsmPrimitive.getFilteredList(segment.firstNode().getReferrers(), Way.class),
+        OsmPrimitive.getFilteredList(segment.lastNode().getReferrers(), Way.class));
+    ways.remove(segment);
+    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() )
+            save = true;
+        if( !save )
+        iter.remove();
+    }
+    if( ways.isEmpty() )
+        return null; // well...
+    Way target = ways.get(0);
+
+    // time to create a new multipolygon relation and a command stack
+    List<Command> commands = new ArrayList<>();
+    Relation newRelation = new Relation();
+    newRelation.put("type", "multipolygon");
+    newRelation.addMember(new RelationMember("outer", segment));
+    Collection<String> linearTags = Main.pref.getCollection(PREF_MULTIPOLY + "lineartags", CreateMultipolygonAction.DEFAULT_LINEAR_TAGS);
+    Way segmentCopy = new Way(segment);
+    boolean changed = false;
+    for( String key : segmentCopy.keySet() ) {
+        if( !linearTags.contains(key) ) {
+        newRelation.put(key, segmentCopy.get(key));
+        segmentCopy.remove(key);
+        changed = true;
+        }
+    }
+    if( changed )
+        commands.add(new ChangeCommand(segment, segmentCopy));
+
+    // now split the way, at last
+    List<Way> newWays = new ArrayList<>(splitWay(target, segment.firstNode(), segment.lastNode(), commands));
+
+    Way addingWay = null;
+    if( target.isClosed() ) {
+        Way utarget = newWays.get(1);
+        Way alternate = newWays.get(0);
+        List<Node> testRing = new ArrayList<>(segment.getNodes());
+        closePolygon(testRing, utarget.getNodes());
+        addingWay = segmentInsidePolygon(alternate.getNode(0), alternate.getNode(1), testRing) ? alternate : utarget;
+    } else {
+        for( Way w : newWays ) {
+        if( (w.firstNode().equals(segment.firstNode()) && w.lastNode().equals(segment.lastNode()))
+            || (w.firstNode().equals(segment.lastNode()) && w.lastNode().equals(segment.firstNode())) ) {
+            addingWay = w;
+            break;
+        }
+        }
+    }
+    newRelation.addMember(new RelationMember("outer", addingWay.getUniqueId() == target.getUniqueId() ? target : addingWay));
+    commands.add(new AddCommand(newRelation));
+    resultingCommands.add(new SequenceCommand(tr("Complete multipolygon for way {0}",
+        DefaultNameFormatter.getInstance().format(segment)), commands));
+    return newRelation;
     }
 
@@ -292,9 +292,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) )
-		result.add(item);
-	return result;
+    List<T> result = new ArrayList<>();
+    for( T item : list1 )
+        if( list2.contains(item) )
+        result.add(item);
+    return result;
     }
     
@@ -303,54 +303,54 @@
      */
     public static Relation attachRingToNeighbours( Way ring, List<Command> resultingCommands ) {
-	if( !ring.isClosed() || ring.isIncomplete() )
-	    return null;
-	Map<Way, Boolean> touchingWays = new HashMap<>();
-	for( Node n : ring.getNodes() ) {
-	    for( OsmPrimitive p : n.getReferrers() ) {
-		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((Way)p) )
-				touchingWays.put((Way)p, Boolean.TRUE);
-			    else
-				touchingWays.put((Way)p, Boolean.FALSE);
-			    break;
-			}
-		    }
-		}
-	    }
-	}
-	
-	List<TheRing> otherWays = new ArrayList<>();
-	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
-	List<Command> commands = new ArrayList<>();
-	TheRing theRing = new TheRing(ring); // this is actually useful
-	
-	for( TheRing otherRing : otherWays )
-	    theRing.collide(otherRing);
-	
-	theRing.putSourceWayFirst();
-	for( TheRing otherRing : otherWays )
-	    otherRing.putSourceWayFirst();
-	
-	Map<Relation, Relation> relationCache = new HashMap<>();
-	for( TheRing otherRing : otherWays )
-	    commands.addAll(otherRing.getCommands(false, relationCache));
-	commands.addAll(theRing.getCommands(relationCache));
-	TheRing.updateCommandsWithRelations(commands, relationCache);
-	resultingCommands.add(new SequenceCommand(tr("Complete multipolygon for way {0}",
-		DefaultNameFormatter.getInstance().format(ring)), commands));
-	return theRing.getRelation();
+    if( !ring.isClosed() || ring.isIncomplete() )
+        return null;
+    Map<Way, Boolean> touchingWays = new HashMap<>();
+    for( Node n : ring.getNodes() ) {
+        for( OsmPrimitive p : n.getReferrers() ) {
+        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((Way)p) )
+                touchingWays.put((Way)p, Boolean.TRUE);
+                else
+                touchingWays.put((Way)p, Boolean.FALSE);
+                break;
+            }
+            }
+        }
+        }
+    }
+    
+    List<TheRing> otherWays = new ArrayList<>();
+    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
+    List<Command> commands = new ArrayList<>();
+    TheRing theRing = new TheRing(ring); // this is actually useful
+    
+    for( TheRing otherRing : otherWays )
+        theRing.collide(otherRing);
+    
+    theRing.putSourceWayFirst();
+    for( TheRing otherRing : otherWays )
+        otherRing.putSourceWayFirst();
+    
+    Map<Relation, Relation> relationCache = new HashMap<>();
+    for( TheRing otherRing : otherWays )
+        commands.addAll(otherRing.getCommands(false, relationCache));
+    commands.addAll(theRing.getCommands(relationCache));
+    TheRing.updateCommandsWithRelations(commands, relationCache);
+    resultingCommands.add(new SequenceCommand(tr("Complete multipolygon for way {0}",
+        DefaultNameFormatter.getInstance().format(ring)), commands));
+    return theRing.getRelation();
     }
 }
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/TheRing.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/TheRing.java	(revision 30737)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/TheRing.java	(revision 30738)
@@ -36,30 +36,30 @@
 
     public TheRing( Way source ) {
-	this.source = source;
-	segments = new ArrayList<>(1);
-	segments.add(new RingSegment(source));
+    this.source = source;
+    segments = new ArrayList<>(1);
+    segments.add(new RingSegment(source));
     }
     
     public static boolean areAllOfThoseRings( Collection<Way> ways ) {
-	List<Way> rings = new ArrayList<>();
-	for( Way way : ways ) {
-	    if( way.isClosed() )
-		rings.add(way);
-	    else
-		return false;
-	}
-	if( rings.isEmpty() || ways.size() == 1 )
-	    return false;
-
-	// check for non-containment of rings
-	for( int i = 0; i < rings.size() - 1; i++ ) {
-	    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 )
-		    return false;
-	    }
-	}
-
-	return true;
+    List<Way> rings = new ArrayList<>();
+    for( Way way : ways ) {
+        if( way.isClosed() )
+        rings.add(way);
+        else
+        return false;
+    }
+    if( rings.isEmpty() || ways.size() == 1 )
+        return false;
+
+    // check for non-containment of rings
+    for( int i = 0; i < rings.size() - 1; i++ ) {
+        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 )
+            return false;
+        }
+    }
+
+    return true;
     }
 
@@ -69,49 +69,49 @@
      */
     public static List<Relation> makeManySimpleMultipolygons( Collection<Way> selection, List<Command> commands ) {
-	log("---------------------------------------");
-	List<TheRing> rings = new ArrayList<>(selection.size());
-	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++ )
-		rings.get(i).collide(rings.get(j));
-	redistributeSegments(rings);
-	List<Relation> relations = new ArrayList<>();
-	Map<Relation, Relation> relationCache = new HashMap<>();
-	for( TheRing r : rings ) {
-	    commands.addAll(r.getCommands(relationCache));
-	    relations.add(r.getRelation());
-	}
-	updateCommandsWithRelations(commands, relationCache);
-	return relations;
+    log("---------------------------------------");
+    List<TheRing> rings = new ArrayList<>(selection.size());
+    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++ )
+        rings.get(i).collide(rings.get(j));
+    redistributeSegments(rings);
+    List<Relation> relations = new ArrayList<>();
+    Map<Relation, Relation> relationCache = new HashMap<>();
+    for( TheRing r : rings ) {
+        commands.addAll(r.getCommands(relationCache));
+        relations.add(r.getRelation());
+    }
+    updateCommandsWithRelations(commands, relationCache);
+    return relations;
     }
 
     public void collide( TheRing other ) {
-	boolean collideNoted = false;
-	for( int i = 0; i < segments.size(); i++ ) {
-	    RingSegment segment1 = segments.get(i);
-	    if( !segment1.isReference() ) {
-		for( int j = 0; j < other.segments.size(); j++ ) {
-		    RingSegment segment2 = other.segments.get(j);
-		    if( !segment2.isReference() ) {
-			log("Comparing " + segment1 + " and " + segment2);
-			Node[] split = getSplitNodes(segment1.getNodes(), segment2.getNodes(), segment1.isRing(), segment2.isRing());
-			if( split != null ) {
-			    if( !collideNoted ) {
-				log("Rings for ways " + source.getUniqueId() + " and " + other.source.getUniqueId() + " collide.");
-				collideNoted = true;
-			    }
-			    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);
-			    segment.makeReference(otherSegment);
-			}
-		    }
-		    if( segment1.isReference() )
-			break;
-		}
-	    }
-	}
+    boolean collideNoted = false;
+    for( int i = 0; i < segments.size(); i++ ) {
+        RingSegment segment1 = segments.get(i);
+        if( !segment1.isReference() ) {
+        for( int j = 0; j < other.segments.size(); j++ ) {
+            RingSegment segment2 = other.segments.get(j);
+            if( !segment2.isReference() ) {
+            log("Comparing " + segment1 + " and " + segment2);
+            Node[] split = getSplitNodes(segment1.getNodes(), segment2.getNodes(), segment1.isRing(), segment2.isRing());
+            if( split != null ) {
+                if( !collideNoted ) {
+                log("Rings for ways " + source.getUniqueId() + " and " + other.source.getUniqueId() + " collide.");
+                collideNoted = true;
+                }
+                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);
+                segment.makeReference(otherSegment);
+            }
+            }
+            if( segment1.isReference() )
+            break;
+        }
+        }
+    }
     }
     
@@ -120,90 +120,90 @@
      */
     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)) )
-	    pos++;
-	boolean collideFound = pos == nodes1.size();
-	if( pos == 0 && isRing1 ) {
-	    // rewind a bit
-	    pos = nodes1.size() - 1;
-	    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);
-		return null;
-	    }
-	    pos = pos == nodes1.size() - 1 ? 0 : pos + 1;
-	}
-	int firstPos = isRing1 ? pos : nodes1.size();
-	while( !collideFound ) {
-	    log("pos=" + pos);
-	    int start1 = pos;
-	    int start2 = nodes2.indexOf(nodes1.get(start1));
-	    int last1 = incrementBy(start1, 1, nodes1.size(), isRing1);
-	    int last2 = start2;
-	    int increment2 = 0;
-	    if( last1 >= 0 ) {
-		last2 = incrementBy(start2, -1, nodes2.size(), isRing2);
-		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)) )
-			increment2 = 1;
-		}
-	    }
-	    log("last1=" + last1 + " last2=" + last2 + " increment2=" + increment2);
-	    if( increment2 != 0 ) {
-		// find the first nodes
-		boolean reachedEnd = false;
-		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)) )
-			reachedEnd = true;
-		    else {
-			last1 = newLast1;
-			last2 = newLast2;
-		    }
-		}
-		log("last1=" + last1 + " last2=" + last2);
-		if( increment2 < 0 ) {
-		    int tmp = start2;
-		    start2 = last2;
-		    last2 = tmp;
-		}
-		return new Node[] {nodes1.get(start1), nodes1.get(last1), nodes2.get(start2), nodes2.get(last2)};
-	    } else {
-		pos = last1;
-		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)) )
-		    collideFound = true;
-	    }
-	}
-	return null;
+    int pos = 0;
+    while( pos < nodes1.size() && !nodes2.contains(nodes1.get(pos)) )
+        pos++;
+    boolean collideFound = pos == nodes1.size();
+    if( pos == 0 && isRing1 ) {
+        // rewind a bit
+        pos = nodes1.size() - 1;
+        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);
+        return null;
+        }
+        pos = pos == nodes1.size() - 1 ? 0 : pos + 1;
+    }
+    int firstPos = isRing1 ? pos : nodes1.size();
+    while( !collideFound ) {
+        log("pos=" + pos);
+        int start1 = pos;
+        int start2 = nodes2.indexOf(nodes1.get(start1));
+        int last1 = incrementBy(start1, 1, nodes1.size(), isRing1);
+        int last2 = start2;
+        int increment2 = 0;
+        if( last1 >= 0 ) {
+        last2 = incrementBy(start2, -1, nodes2.size(), isRing2);
+        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)) )
+            increment2 = 1;
+        }
+        }
+        log("last1=" + last1 + " last2=" + last2 + " increment2=" + increment2);
+        if( increment2 != 0 ) {
+        // find the first nodes
+        boolean reachedEnd = false;
+        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)) )
+            reachedEnd = true;
+            else {
+            last1 = newLast1;
+            last2 = newLast2;
+            }
+        }
+        log("last1=" + last1 + " last2=" + last2);
+        if( increment2 < 0 ) {
+            int tmp = start2;
+            start2 = last2;
+            last2 = tmp;
+        }
+        return new Node[] {nodes1.get(start1), nodes1.get(last1), nodes2.get(start2), nodes2.get(last2)};
+        } else {
+        pos = last1;
+        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)) )
+            collideFound = true;
+        }
+    }
+    return null;
     }
     
     private static int incrementBy( int value, int increment, int limit1, boolean isRing ) {
-	int result = value + increment;
-	if( result < 0 )
-	    return isRing ? result + limit1 : -1;
-	else if( result >= limit1 )
-	    return isRing ? result - limit1 : -1;
-	else
-	    return result;
+    int result = value + increment;
+    if( result < 0 )
+        return isRing ? result + limit1 : -1;
+    else if( result >= limit1 )
+        return isRing ? result - limit1 : -1;
+    else
+        return result;
     }
     
     private boolean areSegmentsEqual( RingSegment seg1, RingSegment seg2 ) {
-	List<Node> nodes1 = seg1.getNodes();
-	List<Node> nodes2 = seg2.getNodes();
-	int size = nodes1.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)) )
-		return false;
-	return true;
+    List<Node> nodes1 = seg1.getNodes();
+    List<Node> nodes2 = seg2.getNodes();
+    int size = nodes1.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)) )
+        return false;
+    return true;
     }
 
@@ -213,28 +213,28 @@
      */
     private RingSegment splitRingAt( int segmentIndex, Node n1, Node n2 ) {
-	if( n1.equals(n2) )
-	    throw new IllegalArgumentException("Both nodes are equal, id=" + n1.getUniqueId());
-	RingSegment segment = segments.get(segmentIndex);
-	boolean isRing = segment.isRing();
-	log("Split segment " + segment + " at nodes " + n1.getUniqueId() + " and " + n2.getUniqueId());
-	boolean reversed = segment.getNodes().indexOf(n2) < segment.getNodes().indexOf(n1);
-	if( reversed && !isRing ) {
-	    // order nodes
-	    Node tmp = n1;
-	    n1 = n2;
-	    n2 = tmp;
-	}
-	RingSegment secondPart = isRing ? segment.split(n1, n2) : segment.split(n1);
-	// if secondPart == null, then n1 == firstNode
-	RingSegment thirdPart = isRing ? null : secondPart == null ? segment.split(n2) : secondPart.split(n2);
-	// if secondPart == null, then thirdPart is between n1 and n2
-	// otherwise, thirdPart is between n2 and lastNode
-	// if thirdPart == null, then n2 == lastNode
-	int pos = segmentIndex + 1;
-	if( secondPart != null )
-	    segments.add(pos++, secondPart);
-	if( thirdPart != null )
-	    segments.add(pos++, thirdPart);
-	return isRing || secondPart == null ? segment : secondPart;
+    if( n1.equals(n2) )
+        throw new IllegalArgumentException("Both nodes are equal, id=" + n1.getUniqueId());
+    RingSegment segment = segments.get(segmentIndex);
+    boolean isRing = segment.isRing();
+    log("Split segment " + segment + " at nodes " + n1.getUniqueId() + " and " + n2.getUniqueId());
+    boolean reversed = segment.getNodes().indexOf(n2) < segment.getNodes().indexOf(n1);
+    if( reversed && !isRing ) {
+        // order nodes
+        Node tmp = n1;
+        n1 = n2;
+        n2 = tmp;
+    }
+    RingSegment secondPart = isRing ? segment.split(n1, n2) : segment.split(n1);
+    // if secondPart == null, then n1 == firstNode
+    RingSegment thirdPart = isRing ? null : secondPart == null ? segment.split(n2) : secondPart.split(n2);
+    // if secondPart == null, then thirdPart is between n1 and n2
+    // otherwise, thirdPart is between n2 and lastNode
+    // if thirdPart == null, then n2 == lastNode
+    int pos = segmentIndex + 1;
+    if( secondPart != null )
+        segments.add(pos++, secondPart);
+    if( thirdPart != null )
+        segments.add(pos++, thirdPart);
+    return isRing || secondPart == null ? segment : secondPart;
     }
 
@@ -246,54 +246,54 @@
      */
     public static void redistributeSegments( List<TheRing> rings ) {
-	// build segments map
-	Map<RingSegment, TheRing> segmentMap = new HashMap<>();
-	for( TheRing ring : rings )
-	    for( RingSegment seg : ring.segments )
-		if( !seg.isReference() )
-		    segmentMap.put(seg, ring);
-
-	// rearrange references
-	for( int i = 0; i < rings.size(); i++ ) {
-	    TheRing ring = rings.get(i);
-	    if( ring.countNonReferenceSegments() == 0 ) {
-		// need to find one non-reference segment
-		for( RingSegment seg : ring.segments ) {
-		    TheRing otherRing = segmentMap.get(seg.references);
-		    if( otherRing.countNonReferenceSegments() > 1 ) {
-			// we could check for >0, but it is prone to deadlocking
-			seg.swapReference();
-		    }
-		}
-	    }
-	}
-
-	// initializing source way for each ring
-	for( TheRing ring : rings )
-	    ring.putSourceWayFirst();
+    // build segments map
+    Map<RingSegment, TheRing> segmentMap = new HashMap<>();
+    for( TheRing ring : rings )
+        for( RingSegment seg : ring.segments )
+        if( !seg.isReference() )
+            segmentMap.put(seg, ring);
+
+    // rearrange references
+    for( int i = 0; i < rings.size(); i++ ) {
+        TheRing ring = rings.get(i);
+        if( ring.countNonReferenceSegments() == 0 ) {
+        // need to find one non-reference segment
+        for( RingSegment seg : ring.segments ) {
+            TheRing otherRing = segmentMap.get(seg.references);
+            if( otherRing.countNonReferenceSegments() > 1 ) {
+            // we could check for >0, but it is prone to deadlocking
+            seg.swapReference();
+            }
+        }
+        }
+    }
+
+    // initializing source way for each ring
+    for( TheRing ring : rings )
+        ring.putSourceWayFirst();
     }
 
     private int countNonReferenceSegments() {
-	int count = 0;
-	for( RingSegment seg : segments )
-	    if( !seg.isReference() )
-		count++;
-	return count;
+    int count = 0;
+    for( RingSegment seg : segments )
+        if( !seg.isReference() )
+        count++;
+    return count;
     }
 
     public void putSourceWayFirst() {
-	for( RingSegment seg : segments ) {
-	    if( !seg.isReference() ) {
-		seg.overrideWay(source);
-		return;
-	    }
-	}
+    for( RingSegment seg : segments ) {
+        if( !seg.isReference() ) {
+        seg.overrideWay(source);
+        return;
+        }
+    }
     }
     
     public List<Command> getCommands() {
-	return getCommands(true, null);
+    return getCommands(true, null);
     }
     
     public List<Command> getCommands( Map<Relation, Relation> relationChangeMap ) {
-	return getCommands(true, relationChangeMap);
+    return getCommands(true, relationChangeMap);
     }
     
@@ -303,76 +303,76 @@
      */
     public List<Command> getCommands( boolean createMultipolygon, Map<Relation, Relation> relationChangeMap ) {
-	Way sourceCopy = new Way(source);
-	if( createMultipolygon ) {
-	    Collection<String> linearTags = Main.pref.getCollection(PREF_MULTIPOLY + "lineartags", CreateMultipolygonAction.DEFAULT_LINEAR_TAGS);
-	    relation = new Relation();
-	    relation.put("type", "multipolygon");
-	    for( String key : sourceCopy.keySet() ) {
+    Way sourceCopy = new Way(source);
+    if( createMultipolygon ) {
+        Collection<String> linearTags = Main.pref.getCollection(PREF_MULTIPOLY + "lineartags", CreateMultipolygonAction.DEFAULT_LINEAR_TAGS);
+        relation = new Relation();
+        relation.put("type", "multipolygon");
+        for( String key : sourceCopy.keySet() ) {
                 if( linearTags.contains(key) ) continue;
                 if( key.equals("natural") && sourceCopy.get("natural").equals("coastline") ) continue;
                 relation.put(key, sourceCopy.get(key));
                 sourceCopy.remove(key);
-	    }
-	}
-
-	// build a map of referencing relations
-	Map<Relation, Integer> referencingRelations = new HashMap<>();
-	List<Command> relationCommands = new ArrayList<>();
-	for( OsmPrimitive p : source.getReferrers() ) {
-	    if( p instanceof Relation ) {
-		Relation rel = null;
-		if( relationChangeMap != null ) {
-		    if( relationChangeMap.containsKey((Relation)p) )
-			rel = relationChangeMap.get((Relation)p);
-		    else {
-			rel = new Relation((Relation)p);
-			relationChangeMap.put((Relation)p, rel);
-		    }
-		} else {		    
-		    rel = new Relation((Relation)p);
-		    relationCommands.add(new ChangeCommand((Relation)p, rel));
-		}
-		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<>();
-	boolean foundOwnWay = false;
-	for( RingSegment seg : segments ) {
-	    boolean needAdding = !seg.isWayConstructed();
-	    Way w = seg.constructWay(seg.isReference() ? null : sourceCopy);
-	    if( needAdding )
-		commands.add(new AddCommand(w));
-	    if( w.equals(source) ) {
-		if( createMultipolygon || !seg.getWayNodes().equals(source.getNodes()) ) {
-		    sourceCopy.setNodes(seg.getWayNodes());
-		    commands.add(new ChangeCommand(source, sourceCopy));
-		}
-		foundOwnWay = true;
-	    } else {
-		for( Relation rel : referencingRelations.keySet() ) {
-		    int relIndex = referencingRelations.get(rel);
-		    rel.addMember(new RelationMember(rel.getMember(relIndex).getRole(), w));
-		}
-	    }
-	    if( createMultipolygon )
-		relation.addMember(new RelationMember("outer", w));
-	}
-	if( !foundOwnWay )
-	    commands.add(new DeleteCommand(source));
-	commands.addAll(relationCommands);
-	if( createMultipolygon )
-	    commands.add(new AddCommand(relation));
-	return commands;
+        }
+    }
+
+    // build a map of referencing relations
+    Map<Relation, Integer> referencingRelations = new HashMap<>();
+    List<Command> relationCommands = new ArrayList<>();
+    for( OsmPrimitive p : source.getReferrers() ) {
+        if( p instanceof Relation ) {
+        Relation rel = null;
+        if( relationChangeMap != null ) {
+            if( relationChangeMap.containsKey((Relation)p) )
+            rel = relationChangeMap.get((Relation)p);
+            else {
+            rel = new Relation((Relation)p);
+            relationChangeMap.put((Relation)p, rel);
+            }
+        } else {            
+            rel = new Relation((Relation)p);
+            relationCommands.add(new ChangeCommand((Relation)p, rel));
+        }
+        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<>();
+    boolean foundOwnWay = false;
+    for( RingSegment seg : segments ) {
+        boolean needAdding = !seg.isWayConstructed();
+        Way w = seg.constructWay(seg.isReference() ? null : sourceCopy);
+        if( needAdding )
+        commands.add(new AddCommand(w));
+        if( w.equals(source) ) {
+        if( createMultipolygon || !seg.getWayNodes().equals(source.getNodes()) ) {
+            sourceCopy.setNodes(seg.getWayNodes());
+            commands.add(new ChangeCommand(source, sourceCopy));
+        }
+        foundOwnWay = true;
+        } else {
+        for( Relation rel : referencingRelations.keySet() ) {
+            int relIndex = referencingRelations.get(rel);
+            rel.addMember(new RelationMember(rel.getMember(relIndex).getRole(), w));
+        }
+        }
+        if( createMultipolygon )
+        relation.addMember(new RelationMember("outer", w));
+    }
+    if( !foundOwnWay )
+        commands.add(new DeleteCommand(source));
+    commands.addAll(relationCommands);
+    if( createMultipolygon )
+        commands.add(new AddCommand(relation));
+    return commands;
     }
     
     public static void updateCommandsWithRelations( List<Command> commands, Map<Relation, Relation> relationCache ) {
-	for( Relation src : relationCache.keySet() )
-	    commands.add(new ChangeCommand(src, relationCache.get(src)));
+    for( Relation src : relationCache.keySet() )
+        commands.add(new ChangeCommand(src, relationCache.get(src)));
     }
 
@@ -381,19 +381,19 @@
      */
     public Relation getRelation() {
-	return relation;
+    return relation;
     }
 
     @Override
     public String toString() {
-	StringBuilder sb = new StringBuilder("TheRing@");
-	sb.append(this.hashCode()).append('[').append("wayId: ").append(source == null ? "null" : source.getUniqueId()).append("; segments: ");
-	if( segments.isEmpty() )
-	    sb.append("empty");
-	else {
-	    sb.append(segments.get(0));
-	    for( int i = 1; i < segments.size(); i++ )
-		sb.append(", ").append(segments.get(i));
-	}
-	return sb.append(']').toString();
+    StringBuilder sb = new StringBuilder("TheRing@");
+    sb.append(this.hashCode()).append('[').append("wayId: ").append(source == null ? "null" : source.getUniqueId()).append("; segments: ");
+    if( segments.isEmpty() )
+        sb.append("empty");
+    else {
+        sb.append(segments.get(0));
+        for( int i = 1; i < segments.size(); i++ )
+        sb.append(", ").append(segments.get(i));
+    }
+    return sb.append(']').toString();
     }
 
@@ -402,11 +402,11 @@
      */
     /*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);
+    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);
     }*/
 
@@ -415,181 +415,181 @@
      */
     /*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);
+    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);
+//    System.out.println(s);
     }
     
     private static class RingSegment {
-	private List<Node> nodes;
-	private RingSegment references;
-	private Way resultingWay = null;
-	private boolean wasTemplateApplied = false;
-	private boolean isRing;
-
-	/*private RingSegment() {
-	}*/
-
-	public RingSegment( Way w ) {
-	    this(w.getNodes());
-	}
-
-	public RingSegment( List<Node> nodes ) {
-	    this.nodes = nodes;
-	    isRing = nodes.size() > 1 && nodes.get(0).equals(nodes.get(nodes.size() - 1));
-	    if( isRing )
-		nodes.remove(nodes.size() - 1);
-	    references = null;
-	}
-
-	/*public RingSegment( RingSegment ref ) {
-	    this.nodes = null;
-	    this.references = ref;
-	}*/
-
-	/**
-	 * Splits this segment at node n. Retains nodes 0..n and moves
-	 * nodes n..N to a separate segment that is returned.
-	 * @param n node at which to split.
-	 * @return new segment, {@code null} if splitting is unnecessary.
-	 */
-	public RingSegment split( Node n ) {
-	    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 )
-		return null;
-	    List<Node> newNodes = new ArrayList<>(nodes.subList(pos, nodes.size()));
-	    nodes.subList(pos + 1, nodes.size()).clear();
-	    return new RingSegment(newNodes);
-	}
-
-	/**
-	 * Split this segment as a way at two nodes. If one of them is null or at the end,
-	 * split as an arc. Note: order of nodes is important.
-	 * @return A new segment from n2 to n1.
-	 */
-	public RingSegment split( Node n1, Node n2 ) {
-	    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) )
-		    return split(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);
-	    }
-	    int pos1 = nodes.indexOf(n1);
-	    int pos2 = nodes.indexOf(n2);
-	    if( pos1 == pos2 )
-		return null;
-
-	    List<Node> newNodes = new ArrayList<>();
-	    if( pos2 > pos1 ) {
-		newNodes.addAll(nodes.subList(pos2, nodes.size()));
-		newNodes.addAll(nodes.subList(0, pos1 + 1));
-		if( pos2 + 1 < nodes.size() )
-		    nodes.subList(pos2 + 1, nodes.size()).clear();
-		if( pos1 > 0 )
-		    nodes.subList(0, pos1).clear();
-	    } else {
-		newNodes.addAll(nodes.subList(pos2, pos1 + 1));
-		nodes.addAll(new ArrayList<>(nodes.subList(0, pos2 + 1)));
-		nodes.subList(0, pos1).clear();
-	    }
-	    isRing = false;
-	    return new RingSegment(newNodes);
-	}
-
-	public List<Node> getNodes() {
-	    return nodes == null ? references.nodes : nodes;
-	}
-
-	public List<Node> getWayNodes() {
-	    if( nodes == null )
-		throw new IllegalArgumentException("Won't give you wayNodes: it is a reference");
-	    List<Node> wayNodes = new ArrayList<>(nodes);
-	    if( isRing )
-		wayNodes.add(wayNodes.get(0));
-	    return wayNodes;
-	}
-
-	public boolean isReference() {
-	    return nodes == null;
-	}
-
-	public boolean isRing() {
-	    return isRing;
-	}
-
-	public void makeReference( RingSegment segment ) {
-	    log(this + " was made a reference to " + segment);
-	    this.nodes = null;
-	    this.references = segment;
-	}
-
-	public void swapReference() {
-	    this.nodes = references.nodes;
-	    references.nodes = null;
-	    references.references = this;
-	    this.references = null;
-	}
-
-	public boolean isWayConstructed() {
-	    return isReference() ? references.isWayConstructed() : resultingWay != null;
-	}
-
-	public Way constructWay( Way template ) {
-	    if( isReference() )
-		return references.constructWay(template);
-	    if( resultingWay == null ) {
-		resultingWay = new Way();
-		resultingWay.setNodes(getWayNodes());
-	    }
-	    if( template != null && !wasTemplateApplied ) {
-		resultingWay.setKeys(template.getKeys());
-		wasTemplateApplied = true;
-	    }
-	    return resultingWay;
-	}
-
-	public void overrideWay( Way source ) {
-	    if( isReference() )
-		references.overrideWay(source);
-	    else {
-		resultingWay = source;
-		wasTemplateApplied = true;
-	    }
-	}
-
-	/**
-	 * 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() )
-		sb.append("references ").append(references.hashCode());
-	    else if( nodes.isEmpty() )
-		sb.append("empty");
-	    else {
-		if( isRing )
-		    sb.append("ring:");
-		sb.append(nodes.get(0).getUniqueId());
-		for( int i = 1; i < nodes.size(); i++ )
-		    sb.append(',').append(nodes.get(i).getUniqueId());
-	    }
-	    return sb.append(']').toString();
-	}
+    private List<Node> nodes;
+    private RingSegment references;
+    private Way resultingWay = null;
+    private boolean wasTemplateApplied = false;
+    private boolean isRing;
+
+    /*private RingSegment() {
+    }*/
+
+    public RingSegment( Way w ) {
+        this(w.getNodes());
+    }
+
+    public RingSegment( List<Node> nodes ) {
+        this.nodes = nodes;
+        isRing = nodes.size() > 1 && nodes.get(0).equals(nodes.get(nodes.size() - 1));
+        if( isRing )
+        nodes.remove(nodes.size() - 1);
+        references = null;
+    }
+
+    /*public RingSegment( RingSegment ref ) {
+        this.nodes = null;
+        this.references = ref;
+    }*/
+
+    /**
+     * Splits this segment at node n. Retains nodes 0..n and moves
+     * nodes n..N to a separate segment that is returned.
+     * @param n node at which to split.
+     * @return new segment, {@code null} if splitting is unnecessary.
+     */
+    public RingSegment split( Node n ) {
+        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 )
+        return null;
+        List<Node> newNodes = new ArrayList<>(nodes.subList(pos, nodes.size()));
+        nodes.subList(pos + 1, nodes.size()).clear();
+        return new RingSegment(newNodes);
+    }
+
+    /**
+     * Split this segment as a way at two nodes. If one of them is null or at the end,
+     * split as an arc. Note: order of nodes is important.
+     * @return A new segment from n2 to n1.
+     */
+    public RingSegment split( Node n1, Node n2 ) {
+        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) )
+            return split(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);
+        }
+        int pos1 = nodes.indexOf(n1);
+        int pos2 = nodes.indexOf(n2);
+        if( pos1 == pos2 )
+        return null;
+
+        List<Node> newNodes = new ArrayList<>();
+        if( pos2 > pos1 ) {
+        newNodes.addAll(nodes.subList(pos2, nodes.size()));
+        newNodes.addAll(nodes.subList(0, pos1 + 1));
+        if( pos2 + 1 < nodes.size() )
+            nodes.subList(pos2 + 1, nodes.size()).clear();
+        if( pos1 > 0 )
+            nodes.subList(0, pos1).clear();
+        } else {
+        newNodes.addAll(nodes.subList(pos2, pos1 + 1));
+        nodes.addAll(new ArrayList<>(nodes.subList(0, pos2 + 1)));
+        nodes.subList(0, pos1).clear();
+        }
+        isRing = false;
+        return new RingSegment(newNodes);
+    }
+
+    public List<Node> getNodes() {
+        return nodes == null ? references.nodes : nodes;
+    }
+
+    public List<Node> getWayNodes() {
+        if( nodes == null )
+        throw new IllegalArgumentException("Won't give you wayNodes: it is a reference");
+        List<Node> wayNodes = new ArrayList<>(nodes);
+        if( isRing )
+        wayNodes.add(wayNodes.get(0));
+        return wayNodes;
+    }
+
+    public boolean isReference() {
+        return nodes == null;
+    }
+
+    public boolean isRing() {
+        return isRing;
+    }
+
+    public void makeReference( RingSegment segment ) {
+        log(this + " was made a reference to " + segment);
+        this.nodes = null;
+        this.references = segment;
+    }
+
+    public void swapReference() {
+        this.nodes = references.nodes;
+        references.nodes = null;
+        references.references = this;
+        this.references = null;
+    }
+
+    public boolean isWayConstructed() {
+        return isReference() ? references.isWayConstructed() : resultingWay != null;
+    }
+
+    public Way constructWay( Way template ) {
+        if( isReference() )
+        return references.constructWay(template);
+        if( resultingWay == null ) {
+        resultingWay = new Way();
+        resultingWay.setNodes(getWayNodes());
+        }
+        if( template != null && !wasTemplateApplied ) {
+        resultingWay.setKeys(template.getKeys());
+        wasTemplateApplied = true;
+        }
+        return resultingWay;
+    }
+
+    public void overrideWay( Way source ) {
+        if( isReference() )
+        references.overrideWay(source);
+        else {
+        resultingWay = source;
+        wasTemplateApplied = true;
+        }
+    }
+
+    /**
+     * 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() )
+        sb.append("references ").append(references.hashCode());
+        else if( nodes.isEmpty() )
+        sb.append("empty");
+        else {
+        if( isRing )
+            sb.append("ring:");
+        sb.append(nodes.get(0).getUniqueId());
+        for( int i = 1; i < nodes.size(); i++ )
+            sb.append(',').append(nodes.get(i).getUniqueId());
+        }
+        return sb.append(']').toString();
+    }
     }
 }
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/AssociatedStreetFixer.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/AssociatedStreetFixer.java	(revision 30737)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/AssociatedStreetFixer.java	(revision 30738)
@@ -19,138 +19,138 @@
 public class AssociatedStreetFixer extends RelationFixer {
 
-	public AssociatedStreetFixer() {
-		super("associatedStreet");
-	}
-
-	@Override
-	public boolean isRelationGood(Relation rel) {
-		for (RelationMember m : rel.getMembers()) {
-    		if (m.getType().equals(OsmPrimitiveType.NODE) && !"house".equals(m.getRole())) {
-    		    setWarningMessage(tr("Node without ''house'' role found"));
-    			return false;
-    		}
-    		if (m.getType().equals(OsmPrimitiveType.WAY) && !("house".equals(m.getRole()) || "street".equals(m.getRole()))) {
-    		    setWarningMessage(tr("Way without ''house'' or ''street'' role found"));
-    		    return false;
-    		}
-    		if (m.getType().equals(OsmPrimitiveType.RELATION) && !"house".equals(m.getRole())) {
-    		    setWarningMessage(tr("Relation without ''house'' role found"));
-    			return false;
-    		}
-    	}
-		// relation should have name
-		if (!rel.hasKey("name")) {
-		    setWarningMessage(tr("Relation does not have name"));
-			return false;
-		}
-		// check that all street members have same name as relation (???)
-		String streetName = rel.get("name");
-		if (streetName == null) streetName = "";
-		for (RelationMember m : rel.getMembers()) {
-			if ("street".equals(m.getRole()) && !streetName.equals(m.getWay().get("name"))) {
-			    String anotherName = m.getWay().get("name");
-			    if (anotherName != null && !anotherName.isEmpty()) {
-    			    setWarningMessage(tr("Relation has streets with different names"));
-    			    return false;
-			    }
-			}
-		}
-		clearWarningMessage();
-		return true;
-	}
+    public AssociatedStreetFixer() {
+        super("associatedStreet");
+    }
 
     @Override
-	public Command fixRelation(Relation source) {
-		// any way with highway tag -> street
-		// any way/point/relation with addr:housenumber=* or building=* or type=multipolygon -> house
-		// name - check which name is most used in street members and add to relation
-		// copy this name to the other street members (???)
-		Relation rel = new Relation(source);
-		boolean fixed = false;
+    public boolean isRelationGood(Relation rel) {
+        for (RelationMember m : rel.getMembers()) {
+            if (m.getType().equals(OsmPrimitiveType.NODE) && !"house".equals(m.getRole())) {
+                setWarningMessage(tr("Node without ''house'' role found"));
+                return false;
+            }
+            if (m.getType().equals(OsmPrimitiveType.WAY) && !("house".equals(m.getRole()) || "street".equals(m.getRole()))) {
+                setWarningMessage(tr("Way without ''house'' or ''street'' role found"));
+                return false;
+            }
+            if (m.getType().equals(OsmPrimitiveType.RELATION) && !"house".equals(m.getRole())) {
+                setWarningMessage(tr("Relation without ''house'' role found"));
+                return false;
+            }
+        }
+        // relation should have name
+        if (!rel.hasKey("name")) {
+            setWarningMessage(tr("Relation does not have name"));
+            return false;
+        }
+        // check that all street members have same name as relation (???)
+        String streetName = rel.get("name");
+        if (streetName == null) streetName = "";
+        for (RelationMember m : rel.getMembers()) {
+            if ("street".equals(m.getRole()) && !streetName.equals(m.getWay().get("name"))) {
+                String anotherName = m.getWay().get("name");
+                if (anotherName != null && !anotherName.isEmpty()) {
+                    setWarningMessage(tr("Relation has streets with different names"));
+                    return false;
+                }
+            }
+        }
+        clearWarningMessage();
+        return true;
+    }
 
-		for (int i = 0; i < rel.getMembersCount(); i++) {
-			RelationMember m = rel.getMember(i);
+    @Override
+    public Command fixRelation(Relation source) {
+        // any way with highway tag -> street
+        // any way/point/relation with addr:housenumber=* or building=* or type=multipolygon -> house
+        // name - check which name is most used in street members and add to relation
+        // copy this name to the other street members (???)
+        Relation rel = new Relation(source);
+        boolean fixed = false;
 
-			if (m.isNode()) {
-				Node node = m.getNode();
-				if (!"house".equals(m.getRole()) &&
-						(node.hasKey("building") || node.hasKey("addr:housenumber"))) {
-					fixed = true;
-					rel.setMember(i, new RelationMember("house", node));
-				}
-			} else if (m.isWay()) {
-				Way way = m.getWay();
-				if (!"street".equals(m.getRole()) && way.hasKey("highway")) {
-					fixed = true;
-					rel.setMember(i, new RelationMember("street", way));
-				} else if (!"house".equals(m.getRole()) &&
-						(way.hasKey("building") || way.hasKey("addr:housenumber"))) {
-					fixed = true;
-					rel.setMember(i,  new RelationMember("house", way));
-				}
-			} else if (m.isRelation()) {
-				Relation relation = m.getRelation();
-				if (!"house".equals(m.getRole()) &&
-						(relation.hasKey("building") || relation.hasKey("addr:housenumber") || "multipolygon".equals(relation.get("type")))) {
-					fixed = true;
-					rel.setMember(i, new RelationMember("house", relation));
-				}
-			}
-		}
+        for (int i = 0; i < rel.getMembersCount(); i++) {
+            RelationMember m = rel.getMember(i);
 
-		// fill relation name
-		Map<String, Integer> streetNames = new HashMap<>();
-		for (RelationMember m : rel.getMembers())
-			if ("street".equals(m.getRole()) && m.isWay()) {
-				String name = m.getWay().get("name");
-				if (name == null || name.isEmpty()) continue;
+            if (m.isNode()) {
+                Node node = m.getNode();
+                if (!"house".equals(m.getRole()) &&
+                        (node.hasKey("building") || node.hasKey("addr:housenumber"))) {
+                    fixed = true;
+                    rel.setMember(i, new RelationMember("house", node));
+                }
+            } else if (m.isWay()) {
+                Way way = m.getWay();
+                if (!"street".equals(m.getRole()) && way.hasKey("highway")) {
+                    fixed = true;
+                    rel.setMember(i, new RelationMember("street", way));
+                } else if (!"house".equals(m.getRole()) &&
+                        (way.hasKey("building") || way.hasKey("addr:housenumber"))) {
+                    fixed = true;
+                    rel.setMember(i,  new RelationMember("house", way));
+                }
+            } else if (m.isRelation()) {
+                Relation relation = m.getRelation();
+                if (!"house".equals(m.getRole()) &&
+                        (relation.hasKey("building") || relation.hasKey("addr:housenumber") || "multipolygon".equals(relation.get("type")))) {
+                    fixed = true;
+                    rel.setMember(i, new RelationMember("house", relation));
+                }
+            }
+        }
 
-				Integer count = streetNames.get(name);
+        // fill relation name
+        Map<String, Integer> streetNames = new HashMap<>();
+        for (RelationMember m : rel.getMembers())
+            if ("street".equals(m.getRole()) && m.isWay()) {
+                String name = m.getWay().get("name");
+                if (name == null || name.isEmpty()) continue;
 
-				streetNames.put(name, count != null? count + 1 : 1);
-			}
-		String commonName = "";
-		Integer commonCount = 0;
-		for (Map.Entry<String, Integer> entry : streetNames.entrySet()) {
-			if (entry.getValue() > commonCount) {
-				commonCount = entry.getValue();
-				commonName = entry.getKey();
-			}
-		}
+                Integer count = streetNames.get(name);
 
-		if (!rel.hasKey("name") && !commonName.isEmpty()) {
-			fixed = true;
-			rel.put("name", commonName);
-		} else {
-			commonName = ""; // set empty common name - if we already have name on relation, do not overwrite it
-		}
+                streetNames.put(name, count != null? count + 1 : 1);
+            }
+        String commonName = "";
+        Integer commonCount = 0;
+        for (Map.Entry<String, Integer> entry : streetNames.entrySet()) {
+            if (entry.getValue() > commonCount) {
+                commonCount = entry.getValue();
+                commonName = entry.getKey();
+            }
+        }
 
-		List<Command> commandList = new ArrayList<>();
-		if (fixed) {
-			commandList.add(new ChangeCommand(source, rel));
-		}
+        if (!rel.hasKey("name") && !commonName.isEmpty()) {
+            fixed = true;
+            rel.put("name", commonName);
+        } else {
+            commonName = ""; // set empty common name - if we already have name on relation, do not overwrite it
+        }
 
-		/*if (!commonName.isEmpty())
-		// fill common name to streets
-		for (RelationMember m : rel.getMembers())
-			if ("street".equals(m.getRole()) && m.isWay()) {
-				String name = m.getWay().get("name");
-				if (commonName.equals(name)) continue;
+        List<Command> commandList = new ArrayList<>();
+        if (fixed) {
+            commandList.add(new ChangeCommand(source, rel));
+        }
 
-				// TODO: ask user if he really wants to overwrite street name??
+        /*if (!commonName.isEmpty())
+        // fill common name to streets
+        for (RelationMember m : rel.getMembers())
+            if ("street".equals(m.getRole()) && m.isWay()) {
+                String name = m.getWay().get("name");
+                if (commonName.equals(name)) continue;
 
-				Way oldWay = m.getWay();
-				Way newWay = new Way(oldWay);
-				newWay.put("name", commonName);
+                // TODO: ask user if he really wants to overwrite street name??
 
-				commandList.add(new ChangeCommand(oldWay, newWay));
-			}
-		*/
-		// return results
-		if (commandList.size() == 0)
-			return null;
-		if (commandList.size() == 1)
-			return commandList.get(0);
-		return new SequenceCommand(tr("fix associatedStreet relation"), commandList);
-	}
+                Way oldWay = m.getWay();
+                Way newWay = new Way(oldWay);
+                newWay.put("name", commonName);
+
+                commandList.add(new ChangeCommand(oldWay, newWay));
+            }
+        */
+        // return results
+        if (commandList.size() == 0)
+            return null;
+        if (commandList.size() == 1)
+            return commandList.get(0);
+        return new SequenceCommand(tr("fix associatedStreet relation"), commandList);
+    }
 }
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/BoundaryFixer.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/BoundaryFixer.java	(revision 30737)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/BoundaryFixer.java	(revision 30738)
@@ -16,21 +16,21 @@
 public class BoundaryFixer extends MultipolygonFixer {
 
-	public BoundaryFixer() {
-		super("boundary", "multipolygon");
-	}
+    public BoundaryFixer() {
+        super("boundary", "multipolygon");
+    }
 
-	/**
-	 * For boundary relations both "boundary" and "multipolygon" types are applicable, but
-	 * it should also have key boundary=administrative to be fully boundary.
-	 * @see http://wiki.openstreetmap.org/wiki/Relation:boundary
-	 */
-	@Override
-	public boolean isFixerApplicable(Relation rel) {
-		return super.isFixerApplicable(rel) && "administrative".equals(rel.get("boundary"));
-	}
+    /**
+     * For boundary relations both "boundary" and "multipolygon" types are applicable, but
+     * it should also have key boundary=administrative to be fully boundary.
+     * @see http://wiki.openstreetmap.org/wiki/Relation:boundary
+     */
+    @Override
+    public boolean isFixerApplicable(Relation rel) {
+        return super.isFixerApplicable(rel) && "administrative".equals(rel.get("boundary"));
+    }
 
-	@Override
-	public boolean isRelationGood(Relation rel) {
-		for( RelationMember m : rel.getMembers() ) {
+    @Override
+    public boolean isRelationGood(Relation rel) {
+        for( RelationMember m : rel.getMembers() ) {
             if (m.getType().equals(OsmPrimitiveType.RELATION) && !"subarea".equals(m.getRole())) {
                 setWarningMessage(tr("Relation without ''subarea'' role found"));
@@ -43,29 +43,29 @@
             if (m.getType().equals(OsmPrimitiveType.WAY) && !("outer".equals(m.getRole()) || "inner".equals(m.getRole()))) {
                 setWarningMessage(tr("Way without ''inner'' or ''outer'' role found"));
-				return false;
+                return false;
             }
         }
-		clearWarningMessage();
-		return true;
-	}
+        clearWarningMessage();
+        return true;
+    }
 
-	@Override
-	public Command fixRelation(Relation rel) {
-		Relation r = rel;
-		Relation rr = fixMultipolygonRoles(r);
-		boolean fixed = false;
-		if (rr != null) {
-			fixed = true;
-			r = rr;
-		}
-		rr = fixBoundaryRoles(r);
-		if (rr != null) {
-			fixed = true;
-			r = rr;
-		}
-		return fixed ? new ChangeCommand(rel, r) : null;
-	}
+    @Override
+    public Command fixRelation(Relation rel) {
+        Relation r = rel;
+        Relation rr = fixMultipolygonRoles(r);
+        boolean fixed = false;
+        if (rr != null) {
+            fixed = true;
+            r = rr;
+        }
+        rr = fixBoundaryRoles(r);
+        if (rr != null) {
+            fixed = true;
+            r = rr;
+        }
+        return fixed ? new ChangeCommand(rel, r) : null;
+    }
 
-	private Relation fixBoundaryRoles( Relation source ) {
+    private Relation fixBoundaryRoles( Relation source ) {
         Relation r = new Relation(source);
         boolean fixed = false;
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/MultipolygonFixer.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/MultipolygonFixer.java	(revision 30737)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/MultipolygonFixer.java	(revision 30738)
@@ -22,31 +22,31 @@
 public class MultipolygonFixer extends RelationFixer {
 
-	public MultipolygonFixer() {
-		super("multipolygon");
-	}
+    public MultipolygonFixer() {
+        super("multipolygon");
+    }
 
-	protected MultipolygonFixer(String...types) {
-		super(types);
-	}
+    protected MultipolygonFixer(String...types) {
+        super(types);
+    }
 
 
-	@Override
-	public boolean isRelationGood(Relation rel) {
-		for (RelationMember m : rel.getMembers())
-			if (m.getType().equals(OsmPrimitiveType.WAY) && !("outer".equals(m.getRole()) || "inner".equals(m.getRole()))) {
-			    setWarningMessage(tr("Way without ''inner'' or ''outer'' role found"));
-			    return false;
-			}
-		clearWarningMessage();
-		return true;
-	}
+    @Override
+    public boolean isRelationGood(Relation rel) {
+        for (RelationMember m : rel.getMembers())
+            if (m.getType().equals(OsmPrimitiveType.WAY) && !("outer".equals(m.getRole()) || "inner".equals(m.getRole()))) {
+                setWarningMessage(tr("Way without ''inner'' or ''outer'' role found"));
+                return false;
+            }
+        clearWarningMessage();
+        return true;
+    }
 
-	@Override
-	public Command fixRelation(Relation rel) {
-		Relation rr = fixMultipolygonRoles(rel);
-		return rr != null? new ChangeCommand(rel, rr) : null;
-	}
+    @Override
+    public Command fixRelation(Relation rel) {
+        Relation rr = fixMultipolygonRoles(rel);
+        return rr != null? new ChangeCommand(rel, rr) : null;
+    }
 
-	/**
+    /**
      * Basically, created multipolygon from scratch, and if successful, replace roles with new ones.
      */
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/NothingFixer.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/NothingFixer.java	(revision 30737)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/NothingFixer.java	(revision 30738)
@@ -9,20 +9,20 @@
 public class NothingFixer extends RelationFixer {
 
-	public NothingFixer() {
-		super("");
-	}
-	@Override
-	public boolean isFixerApplicable(Relation rel) {
-		return true;
-	}
-	@Override
-	public boolean isRelationGood(Relation rel) {
-		return true;
-	}
+    public NothingFixer() {
+        super("");
+    }
+    @Override
+    public boolean isFixerApplicable(Relation rel) {
+        return true;
+    }
+    @Override
+    public boolean isRelationGood(Relation rel) {
+        return true;
+    }
 
-	@Override
-	public Command fixRelation(Relation rel) {
-		return null;
-	}
+    @Override
+    public Command fixRelation(Relation rel) {
+        return null;
+    }
 
 }
Index: applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/RelationFixer.java
===================================================================
--- applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/RelationFixer.java	(revision 30737)
+++ applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/RelationFixer.java	(revision 30738)
@@ -15,58 +15,58 @@
 public abstract class RelationFixer {
 
-	private List<String> applicableTypes;
-	private SortAndFixAction sortAndFixAction;
+    private List<String> applicableTypes;
+    private SortAndFixAction sortAndFixAction;
 
-	/**
-	 * Construct new RelationFixer by a list of applicable types
-	 * @param types
-	 */
-	public RelationFixer(String... types) {
-	    applicableTypes = new ArrayList<>();
-		for(String type: types) {
-			applicableTypes.add(type);
-		}
-	}
+    /**
+     * Construct new RelationFixer by a list of applicable types
+     * @param types
+     */
+    public RelationFixer(String... types) {
+        applicableTypes = new ArrayList<>();
+        for(String type: types) {
+            applicableTypes.add(type);
+        }
+    }
 
-	/**
-	 * Check if given relation is of needed type. You may override this method to check first type
-	 * and then check desired relation properties.
-	 * Note that this only verifies if current RelationFixer can be used to check and fix given relation
-	 * Deeper relation checking is at {@link isRelationGood}
-	 *
-	 * @param rel Relation to check
-	 * @return true if relation can be verified by current RelationFixer
-	 */
-	public boolean isFixerApplicable(Relation rel) {
-		if (rel == null)
-			return false;
-		if (!rel.hasKey("type"))
-			return false;
+    /**
+     * Check if given relation is of needed type. You may override this method to check first type
+     * and then check desired relation properties.
+     * Note that this only verifies if current RelationFixer can be used to check and fix given relation
+     * Deeper relation checking is at {@link isRelationGood}
+     *
+     * @param rel Relation to check
+     * @return true if relation can be verified by current RelationFixer
+     */
+    public boolean isFixerApplicable(Relation rel) {
+        if (rel == null)
+            return false;
+        if (!rel.hasKey("type"))
+            return false;
 
-		String type = rel.get("type");
-		for(String oktype: applicableTypes)
-			if (oktype.equals(type))
-				return true;
+        String type = rel.get("type");
+        for(String oktype: applicableTypes)
+            if (oktype.equals(type))
+                return true;
 
-		return false;
-	}
+        return false;
+    }
 
-	/**
-	 * Check if given relation is OK. That means if all roles are given properly, all tags exist as expected etc.
-	 * Should be written in children classes.
-	 *
-	 * @param rel Relation to verify
-	 * @return true if given relation is OK
-	 */
-	public abstract boolean isRelationGood(Relation rel);
+    /**
+     * Check if given relation is OK. That means if all roles are given properly, all tags exist as expected etc.
+     * Should be written in children classes.
+     *
+     * @param rel Relation to verify
+     * @return true if given relation is OK
+     */
+    public abstract boolean isRelationGood(Relation rel);
 
-	/**
-	 * Fix relation and return new relation with fixed tags, roles etc.
-	 * Note that is not obligatory to return true for isRelationGood for new relation
-	 *
-	 * @param rel Relation to fix
-	 * @return command that fixes the relation {@code null} if it cannot be fixed or is already OK
-	 */
-	public abstract Command fixRelation(Relation rel);
+    /**
+     * Fix relation and return new relation with fixed tags, roles etc.
+     * Note that is not obligatory to return true for isRelationGood for new relation
+     *
+     * @param rel Relation to fix
+     * @return command that fixes the relation {@code null} if it cannot be fixed or is already OK
+     */
+    public abstract Command fixRelation(Relation rel);
 
     public void setFixAction(SortAndFixAction sortAndFixAction) {
