Index: applications/editors/josm/plugins/czechaddress/build.xml
===================================================================
--- applications/editors/josm/plugins/czechaddress/build.xml	(revision 18881)
+++ applications/editors/josm/plugins/czechaddress/build.xml	(revision 18892)
@@ -75,5 +75,6 @@
             <arg value="."/>
         </exec>
-        <xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true"/>
+        <xmlproperty file="REVISION" prefix="version"
+                     keepRoot="false" collapseAttributes="true"/>
         <delete file="REVISION"/>
     </target>
@@ -94,9 +95,14 @@
 
     <target name="run" depends="compile">
-        <fail message="You must firstly compile the JOSM itself"><condition><not>
-            <resourcecount count="1" when="gt">
-                <fileset id="josm" dir="${josm.classpath}" includes="*"/>
-            </resourcecount>
-        </not></condition></fail>
+        <fail message="You must firstly compile the JOSM itself">
+            <condition>
+                <not>
+                    <resourcecount count="1" when="gt">
+                        <fileset  includes="*" id="josm"
+                                 dir="${josm.classpath}"/>
+                    </resourcecount>
+                </not>
+            </condition>
+        </fail>
 
         <java classname="JOSM" fork="true">
@@ -117,8 +123,13 @@
 
 
-    <target name="profile" depends="compile" description="Profile CzechAddress">
-        <fail unless="netbeans.home">This target can only run inside the NetBeans IDE.</fail>
+    <target name="profile" depends="compile"
+            description="Profile CzechAddress with Netbeans">
+        <fail unless="netbeans.home">
+            This target can only run inside the NetBeans IDE.
+        </fail>
         <nbprofiledirect>
-            <classpath><pathelement location="${plugin.build.dir}"/></classpath>
+            <classpath>
+                <pathelement location="${plugin.build.dir}"/>
+            </classpath>
         </nbprofiledirect>
         <java classname="JOSM" fork="true">
@@ -135,3 +146,35 @@
         </java>
     </target>
+
+    <target name="debug" depends="compile"
+            description="Debug CzechAddress with Netbeans">
+        <fail message="You must firstly compile the JOSM itself">
+            <condition>
+                <not>
+                    <resourcecount count="1" when="gt">
+                        <fileset dir="${josm.classpath}"
+                                 includes="*" id="josm"/>
+                    </resourcecount>
+                </not>
+            </condition>
+        </fail>
+        <nbjpdastart addressproperty="jpda.address"
+                     name="czechaddress"
+                     transport="dt_socket"/>
+        <java classname="JOSM" fork="true">
+            <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
+            <jvmarg value="-Xmx1024m"/>
+            <jvmarg value="-Xdebug"/>
+            <jvmarg value="-ea"/>
+            <classpath>
+                <pathelement location="${plugin.build.dir}"/>
+                <pathelement path="${java.class.path}"/>
+            </classpath>
+            <classpath>
+                <pathelement location="${josm}"/>
+                <pathelement path="${java.class.path}"/>
+            </classpath>
+        </java>
+    </target>
+
 </project>
Index: applications/editors/josm/plugins/czechaddress/nbproject/project.xml
===================================================================
--- applications/editors/josm/plugins/czechaddress/nbproject/project.xml	(revision 18881)
+++ applications/editors/josm/plugins/czechaddress/nbproject/project.xml	(revision 18892)
@@ -46,4 +46,8 @@
                     <target>dist</target>
                 </action>
+                <action name="debug">
+                    <!--<script>nbproject/ide-targets.xml</script>-->
+                    <target>debug</target>
+                </action>
             </ide-actions>
             <export>
@@ -72,4 +76,5 @@
                     <ide-action name="javadoc"/>
                     <ide-action name="run"/>
+                    <ide-action name="debug"/>
                 </context-menu>
             </view>
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/actions/SplitAreaByEmptyWayAction.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/actions/SplitAreaByEmptyWayAction.java	(revision 18881)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/actions/SplitAreaByEmptyWayAction.java	(revision 18892)
@@ -7,4 +7,5 @@
 import java.util.Collection;
 import java.util.Collections;
+import java.util.List;
 
 import javax.swing.JOptionPane;
@@ -12,4 +13,5 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Relation;
@@ -111,21 +113,22 @@
     private int splitArea(Way area, Way border, Way newArea1, Way newArea2) {
 
-        Way tempBorder = new Way(border);
+        for (Relation r : Main.main.getCurrentDataSet().getRelations())
+            for (RelationMember rm : r.getMembers())
+                if (rm.refersTo(area) || rm.refersTo(border))
+                    return 2;
 
-        int index1 = area.getNodes().indexOf(tempBorder.firstNode());
-        int index2 = area.getNodes().indexOf(tempBorder.lastNode());
+        List<Node> bordNodes = border.getNodes();
+        List<Node> areaNodes = area.getNodes();
+
+        int index1 = areaNodes.indexOf(bordNodes.get(0));
+        int index2 = areaNodes.indexOf(bordNodes.get(bordNodes.size()-1));
         if (index1 == index2)
             return 1;
 
         if (index1 > index2) {
-            Collections.reverse(tempBorder.getNodes());
-            index1 = area.getNodes().indexOf(tempBorder.firstNode());
-            index2 = area.getNodes().indexOf(tempBorder.lastNode());
+            Collections.reverse(areaNodes);
+            index1 = areaNodes.indexOf(bordNodes.get(0));
+            index2 = areaNodes.indexOf(bordNodes.get(bordNodes.size()-1));
         }
-
-        for (Relation relation : Main.main.getCurrentDataSet().getRelations())
-            for (RelationMember areaMember : relation.getMembers())
-                if (area.equals(areaMember.getMember()))
-                    return 2;
 
         for (String key : area.keySet()) {
@@ -134,31 +137,19 @@
         }
 
-        newArea1.getNodes().addAll(area.getNodes().subList(0, index1));
-        newArea1.getNodes().addAll(tempBorder.getNodes());
-        newArea1.getNodes().addAll(area.getNodes().subList(index2, area.getNodes().size()-1));
-        newArea1.getNodes().add(area.getNodes().get(0));
+        List<Node> newNodeList1 = newArea1.getNodes();
+        List<Node> newNodeList2 = newArea1.getNodes();
 
-        Collections.reverse(tempBorder.getNodes());
-        newArea2.getNodes().addAll(area.getNodes().subList(index1, index2));
-        newArea2.getNodes().addAll(tempBorder.getNodes());
-        newArea2.getNodes().add(area.getNodes().get(index1));
+        newNodeList1.addAll(areaNodes.subList(0, index1));
+        newNodeList1.addAll(bordNodes);
+        newNodeList1.addAll(areaNodes.subList(index2 + 1, areaNodes.size()));
 
-        removeDuplicateNodesFromWay(newArea1);
-        removeDuplicateNodesFromWay(newArea2);
+        Collections.reverse(bordNodes);
+        newNodeList2.addAll(areaNodes.subList(index1, index2));
+        newNodeList2.addAll(bordNodes);
+
+        newArea1.setNodes(newNodeList1);
+        newArea2.setNodes(newNodeList2);
 
         return 0;
     }
-
-    /**
-     * Removes all consequent nodes, which are on the same way.
-     */
-    void removeDuplicateNodesFromWay(Way w) {
-        int i=0;
-        while (i<w.getNodes().size()-1) {
-            if (w.getNodes().get(i).equals(w.getNodes().get(i+1)))
-                w.getNodes().remove(i);
-            else
-                i++;
-        }
-    }
 }
