Index: applications/editors/josm/plugins/lakewalker/Lakewalker/lakewalker.py
===================================================================
--- applications/editors/josm/plugins/lakewalker/Lakewalker/lakewalker.py	(revision 6790)
+++ applications/editors/josm/plugins/lakewalker/Lakewalker/lakewalker.py	(revision 6874)
@@ -85,4 +85,5 @@
 def download_landsat(c1, c2, width, height, fname):
     layer = "global_mosaic_base"
+    #style = "IR1"
     style = options.wmslayer
 
@@ -356,4 +357,6 @@
     # n lat lon - A node
     # x - End of data
+    countnodes = 0
+    
     print "s %s" % len(lakelist)
     for nodelist in lakelist:
@@ -361,4 +364,12 @@
         for node in nodelist:
             print "n %.7f %.7f" % (node[0], node[1])
+            
+            countnodes = countnodes + 1
+            if options.MAXLEN == countnodes:
+              print "x"
+              print "t %s" % len(nodelist)
+              print "n %.7f %.7f" % (node[0], node[1])
+              countnodes = 0
+              
     print "x"
 
@@ -432,5 +443,5 @@
     parser.add_option("--threshold", "-t", type="int", default="35", metavar="VALUE", help="Maximum gray value to accept as water (based on Landsat IR-1 data). Can be in the range 0-255. Defaults to 35.")
     parser.add_option("--maxnodes", type="int", default="50000", metavar="N", help="Maximum number of nodes to generate before bailing out. Defaults to 50000.")
-    parser.add_option("--waylength", type="int", default=250, metavar="MAXLEN", help="Maximum nuber of nodes allowed in one way. Defaults to 250.")
+    parser.add_option("--waylength", type="int", dest="MAXLEN", default=500, metavar="MAXLEN", help="Maximum nuber of nodes allowed in one way. Defaults to 250.")
     parser.add_option("--landsat-res", type="int", default=4000, dest="resolution", metavar="RES", help="Resolution of Landsat tiles, measured in pixels per degree. Defaults to 4000.")
     parser.add_option("--tilesize", type="int", default=2000, help="Size of one landsat tile, measured in pixels. Defaults to 2000.")
Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java	(revision 6790)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java	(revision 6874)
@@ -95,4 +95,5 @@
     target += " --top=" + topLeft.lat();
     target += " --bottom=" + botRight.lat();
+    target += " --waylength=" + Main.pref.get(LakewalkerPreferences.PREF_MAX_SEG, "500");
     target += " --maxnodes=" + Main.pref.get(LakewalkerPreferences.PREF_MAX_NODES, "50000");
     target += " --threshold=" + Main.pref.get(LakewalkerPreferences.PREF_THRESHOLD, "35");
Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPreferences.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPreferences.java	(revision 6790)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPreferences.java	(revision 6874)
@@ -74,5 +74,5 @@
     
     pythonConfig.setValue(Main.pref.get(PREF_PYTHON, "python.exe"));
-    maxSegsConfig.setValue(Main.pref.get(PREF_MAX_SEG, "250"));
+    maxSegsConfig.setValue(Main.pref.get(PREF_MAX_SEG, "500"));
     maxNodesConfig.setValue(Main.pref.get(PREF_MAX_NODES, "50000"));
     thresholdConfig.setValue(Main.pref.get(PREF_THRESHOLD, "35"));
Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerReader.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerReader.java	(revision 6790)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerReader.java	(revision 6874)
@@ -59,5 +59,7 @@
     try {
     	
-      Node fn = null; //new Node(new LatLon(0,0));
+	  Node n = null;  // The current node being created
+	  Node tn = null; // The last node of the previous way
+      Node fn = null; // Node to hold the first node in the trace
     	
       while ((line = input.readLine()) != null) {
@@ -70,16 +72,27 @@
         case 'n':
           String[] tokens = line.split(" ");
-          try {
-            LatLon ll = new LatLon(Double.parseDouble(tokens[1])+northOffset, Double.parseDouble(tokens[2])+eastOffset);
-            Node n = new Node(ll);
-            commands.add(new AddCommand(n));
-            way.nodes.add(n);
-            if(fn==null){
-            	fn = n;
-            }
+          
+          if(tn==null){
+		      try {        	
+		        LatLon ll = new LatLon(Double.parseDouble(tokens[1])+northOffset, Double.parseDouble(tokens[2])+eastOffset);
+		        n = new Node(ll);
+		        if(fn==null){
+		          fn = n;
+		        }
+		        commands.add(new AddCommand(n));
+		      }
+	          catch (Exception ex) {
+	        	  
+		      }
+          
+          } else {
+            // If there is a last node, and this node has the same coordinates
+            // then we substitute for the previous node
+      		n = tn;
+        	tn = null;       	
           }
-          catch (Exception ex) {
-
-          }
+	      
+	      way.nodes.add(n);
+          
           break;
 
@@ -99,4 +112,9 @@
           
           break;
+        
+        case 't':      	
+        	way = new Way();
+        	tn = n;
+        	break;
           
         case 'e':
@@ -107,4 +125,6 @@
       } 
       input.close();
+
+      // Add the start node to the end of the trace to form a closed shape 
       way.nodes.add(fn);
     }
