Index: applications/editors/josm/plugins/contourmerge/build.xml
===================================================================
--- applications/editors/josm/plugins/contourmerge/build.xml	(revision 25613)
+++ applications/editors/josm/plugins/contourmerge/build.xml	(revision 25617)
@@ -27,5 +27,5 @@
 <project name="contourmerge" default="dist" basedir=".">
 
-	<property name="commit.message" value="Fixed: unexpected intersections after drag-and-drop" />
+	<property name="commit.message" value="fixed broken test cases submitted by Lennard; fixed ant script again" />
 	<property name="plugin.main.version" value="3835" />
 
@@ -72,5 +72,5 @@
 	<target name="dist" depends="compile,revision">
 		<echo message="creating ${plugin.jar} for version ${version.entry.commit.revision} ... " />
-		<copy todir="${plugin.build.dir}/images">
+		<copy todir="${plugin.build.dir}">
 			<fileset dir="images">
 				<exclude name="*.svg" />
Index: applications/editors/josm/plugins/contourmerge/src/org/openstreetmap/josm/plugins/contourmerge/ContourMergeModel.java
===================================================================
--- applications/editors/josm/plugins/contourmerge/src/org/openstreetmap/josm/plugins/contourmerge/ContourMergeModel.java	(revision 25613)
+++ applications/editors/josm/plugins/contourmerge/src/org/openstreetmap/josm/plugins/contourmerge/ContourMergeModel.java	(revision 25617)
@@ -39,5 +39,5 @@
  */
 public class ContourMergeModel implements DataSetListener{
-	static private final Logger logger = Logger.getLogger(ContourMergeModel.class.getName());
+	//static private final Logger logger = Logger.getLogger(ContourMergeModel.class.getName());
 	
 	private OsmDataLayer layer;	
@@ -398,5 +398,4 @@
 		List<Node> targetNodes = dropTarget.getNodes();
 		if (! areDirectionAligned(dragSource, dropTarget)) {
-			logger.info("not direction aligned !");
 			Collections.reverse(targetNodes);
 		}
@@ -405,5 +404,5 @@
 		cmds.add(new ChangeCommand(dragSource.getWay(), dragSource.replaceNodes(targetNodes)));
 		
-		// the command to delete nodes we don't need anymore 
+		// the commands to delete nodes we don't need anymore 
 		for (Node n: dragSource.getNodes()) {
 			List<OsmPrimitive> parents = n.getReferrers();
@@ -418,4 +417,12 @@
 	}
 	
+	protected boolean haveSameStartAndEndNode(List<Node> n1, List<Node> n2) {
+		return n1.get(0) == n2.get(0) && n1.get(n1.size()-1) == n2.get(n2.size()-1);
+	}
+	
+	protected boolean haveReversedStartAndEndeNode(List<Node> n1, List<Node> n2) {
+		return n1.get(0) == n2.get(n2.size()-1) && n1.get(n1.size()-1) == n2.get(0);
+	}
+	
 	/**
 	 * <p>Replies true, if the two polylines given by the node lists {@code n1} and
@@ -429,4 +436,14 @@
 	 */
 	protected boolean areDirectionAligned(List<Node> n1, List<Node> n2) {
+		/*
+		 * Check whether n1 and n2 start and end at the same nodes
+		 */
+		if (haveSameStartAndEndNode(n1, n2)) return true;
+		if (haveReversedStartAndEndeNode(n1,n2)) return false;
+		/*
+		 * n1 and n2 have different start or end nodes. Draw an imaginary line
+		 * from the start of n1 to start of n2 and from the end of n1 to the end
+		 * of n2 and check whether they intersect. 
+		 */
 		EastNorth s1 = n1.get(0).getEastNorth();
 		EastNorth s2 = n1.get(n1.size()-1).getEastNorth();
@@ -438,5 +455,4 @@
 		Line2D l2 = new Line2D.Double(s2.getX(), s2.getY(), t2.getX(),t2.getY());
 		return ! l1.intersectsLine(l2);
-
 	}
 	
@@ -452,4 +468,5 @@
 		if (dragSource == null) return false;
 		if (dropTarget == null) return false;
+		
 		return areDirectionAligned(dragSource.getNodes(), dropTarget.getNodes());
 	}
Index: applications/editors/josm/plugins/contourmerge/src/org/openstreetmap/josm/plugins/contourmerge/ContourMergeView.java
===================================================================
--- applications/editors/josm/plugins/contourmerge/src/org/openstreetmap/josm/plugins/contourmerge/ContourMergeView.java	(revision 25613)
+++ applications/editors/josm/plugins/contourmerge/src/org/openstreetmap/josm/plugins/contourmerge/ContourMergeView.java	(revision 25617)
@@ -25,5 +25,5 @@
  */
 public class ContourMergeView implements MapViewPaintable{
-	static private final Logger logger = Logger.getLogger(ContourMergeView.class.getName());
+	//static private final Logger logger = Logger.getLogger(ContourMergeView.class.getName());
 	
 	static private ContourMergeView instance;
@@ -48,5 +48,5 @@
 		Node n = ContourMergePlugin.getModelManager().getActiveModel().getFeedbackNode();
 		if (n == null) return;
-		/* currently no decoration - mouse pointer is chaning if mouse over a node */
+		/* currently no decoration - mouse pointer is changing if mouse over a node */
 	}
 	
@@ -322,4 +322,5 @@
 		ContourMergeModel model = ContourMergePlugin.getModelManager().getActiveModel();
 		if (model == null) return;
+		if (!model.getLayer().isVisible()) return;
 		decorateSelectedNodes(g, mv, bbox);
 		decorateFeedbackNode(g, mv, bbox);		
Index: applications/editors/josm/plugins/contourmerge/src/org/openstreetmap/josm/plugins/contourmerge/WaySlice.java
===================================================================
--- applications/editors/josm/plugins/contourmerge/src/org/openstreetmap/josm/plugins/contourmerge/WaySlice.java	(revision 25613)
+++ applications/editors/josm/plugins/contourmerge/src/org/openstreetmap/josm/plugins/contourmerge/WaySlice.java	(revision 25617)
@@ -16,5 +16,5 @@
  */
 public class WaySlice {
-	static private final Logger logger = Logger.getLogger(WaySlice.class.getName());
+	//static private final Logger logger = Logger.getLogger(WaySlice.class.getName());
 
 	private Way w;
@@ -288,7 +288,7 @@
 				nodes.addAll(w.getNodes().subList(start, end+1));
 			} else {
-				for (int i=start; i>=0; i--) nodes.add(w.getNode(i));
 				// do not add the last node which is the join node common to the node at index 0
-				for (int i=w.getNodesCount()-2; i>=end; i--) nodes.add(w.getNode(i));
+				for (int i=end; i<=w.getNodesCount()-2;i++)nodes.add(w.getNode(i));
+				for (int i=0; i <= start; i++) nodes.add(w.getNode(i));
 			}
 		}
Index: applications/editors/josm/plugins/contourmerge/test/data/test-1.osm
===================================================================
--- applications/editors/josm/plugins/contourmerge/test/data/test-1.osm	(revision 25617)
+++ applications/editors/josm/plugins/contourmerge/test/data/test-1.osm	(revision 25617)
@@ -0,0 +1,33 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<osm version='0.6' generator='JOSM'>
+  <node id='-160' visible='true' lat='1.0599891769798162' lon='-1.9076261779992232' />
+  <node id='-158' visible='true' lat='0.6545810659768819' lon='-1.9216073621978884' />
+  <node id='-156' visible='true' lat='0.4495333255941504' lon='-2.257155782965838' />
+  <node id='-154' visible='true' lat='0.7338019551246027' lon='-2.61134578266534' />
+  <node id='-152' visible='true' lat='1.0972657277443136' lon='-2.5927042037337875' />
+  <node id='-151' visible='true' lat='1.3442103974374202' lon='-2.2012310461711797' />
+  <node id='-148' visible='true' lat='1.0553295762596493' lon='-0.28114841622124587' />
+  <node id='-146' visible='true' lat='0.6592411544022065' lon='-0.2718276267554695' />
+  <node id='-144' visible='true' lat='0.46817430664637166' lon='-0.6120364422563073' />
+  <node id='-142' visible='true' lat='0.6918616495397568' lon='-0.9475848630242568' />
+  <node id='-140' visible='true' lat='1.0879466329839516' lon='-0.9336036788255921' />
+  <node id='-139' visible='true' lat='1.2883004195863688' lon='-0.6353384159207481' />
+  <way id='-153' action='modify' visible='true'>
+    <nd ref='-151' />
+    <nd ref='-152' />
+    <nd ref='-154' />
+    <nd ref='-156' />
+    <nd ref='-158' />
+    <nd ref='-160' />
+    <nd ref='-151' />
+  </way>
+  <way id='-141' action='modify' visible='true'>
+    <nd ref='-139' />
+    <nd ref='-148' />
+    <nd ref='-146' />
+    <nd ref='-144' />
+    <nd ref='-142' />
+    <nd ref='-140' />
+    <nd ref='-139' />
+  </way>
+</osm>
