Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ErrorLayer.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ErrorLayer.java	(revision 4821)
+++ applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ErrorLayer.java	(revision 4843)
@@ -51,5 +51,5 @@
      * Draw all primitives in this layer but do not draw modified ones (they
      * are drawn by the edit layer).
-     * Draw nodes last to overlap the segments they belong to.
+     * Draw nodes last to overlap the ways they belong to.
      */
     @SuppressWarnings("unchecked")
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/GridLayer.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/GridLayer.java	(revision 4821)
+++ applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/GridLayer.java	(revision 4843)
@@ -22,5 +22,5 @@
 
 /**
- * A debug layer for testing the grid cells a segment or way crosses.
+ * A debug layer for testing the grid cells a way crosses.
  * 
  * @author frsantos
@@ -166,16 +166,17 @@
 		}
 
-		public void visit(Segment s) 
-		{
-			for( Point2D p : Util.getSegmentCells(s, gridDetail))
-			{
-		        drawCell( p.getX(), p.getY() );
-			}
-		}
-
 		public void visit(Way w) 
 		{
-			for( Segment s : w.segments )
-				visit(s);
+			Node lastN = null;
+			for (Node n : w.nodes) {
+				if (lastN == null) {
+					lastN = n;
+					continue;
+				}
+				for (Point2D p : Util.getSegmentCells(lastN, n, gridDetail)) {
+					drawCell( p.getX(), p.getY() );
+				}
+				lastN = n;
+			}
 		}
 		
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/OSMValidatorPlugin.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/OSMValidatorPlugin.java	(revision 4821)
+++ applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/OSMValidatorPlugin.java	(revision 4843)
@@ -46,14 +46,10 @@
     { 
     	DuplicateNode.class, 
-    	DuplicateSegment.class, 
-    	SingleNodeSegment.class, 
+    	OverlappingWays.class, 
         UntaggedNode.class, 
-    	TaggedSegment.class, 
         UntaggedWay.class,
-    	UnorderedWay.class, 
     	SpellCheck.class,
-    	OrphanSegment.class, 
-        ReusedSegment.class, 
-        CrossingSegments.class,
+        DuplicatedWayNodes.class, 
+        CrossingWays.class,
         SimilarNamedWays.class,
         Coastlines.class,
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/Test.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/Test.java	(revision 4821)
+++ applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/Test.java	(revision 4843)
@@ -20,5 +20,5 @@
  * A test is a primitive visitor, so that it can access to all data to be
  * validated. These primitives are always visited in the same order: nodes
- * first, then segments, and ways last.
+ * first, then ways.
  * 
  * @author frsantos
@@ -115,5 +115,5 @@
     /**
      * Visits all primitives to be tested. These primitives are always visited
-     * in the same order: nodes first, then segments, and ways last.
+     * in the same order: nodes first, then ways.
      * 
      * @param selection The primitives to be tested
@@ -129,6 +129,4 @@
 
     public void visit(Node n) {}
-
-	public void visit(Segment s) {}
 
 	public void visit(Way w) {}
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/TestError.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/TestError.java	(revision 4821)
+++ applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/TestError.java	(revision 4843)
@@ -251,8 +251,8 @@
          * @param color The color
          */
-        public void drawSegment(Segment s, Color color)
-        {
-            Point p1 = mv.getPoint(s.from.eastNorth);
-            Point p2 = mv.getPoint(s.to.eastNorth);
+        public void drawSegment(Node n1, Node n2, Color color)
+        {
+            Point p1 = mv.getPoint(n1.eastNorth);
+            Point p2 = mv.getPoint(n2.eastNorth);
             g.setColor(color);
             
@@ -292,23 +292,18 @@
         }
 
-        /**
-         * Draw just a line between the points.
-         * White if selected (as always) or green otherwise.
-         */
-        public void visit(Segment ls) 
-        {
-            if( isSegmentVisible(ls) )
-                drawSegment(ls, severity.getColor());
-        }
-        
         public void visit(Way w)
         {
-            for (Segment ls : w.segments)
-            {
-                if (isSegmentVisible(ls))
+			Node lastN = null;
+			for (Node n : w.nodes) {
+				if (lastN == null) {
+					lastN = n;
+					continue;
+				}
+                if (isSegmentVisible(lastN, n))
                 {
-                    drawSegment(ls, severity.getColor());
+                    drawSegment(lastN, n, severity.getColor());
                 }
-            }
+				lastN = n;
+			}
         }
         
@@ -330,8 +325,7 @@
          * @return true if the segment is visible
          */
-        protected boolean isSegmentVisible(Segment ls) {
-            if (ls.incomplete) return false;
-            Point p1 = mv.getPoint(ls.from.eastNorth);
-            Point p2 = mv.getPoint(ls.to.eastNorth);
+        protected boolean isSegmentVisible(Node n1, Node n2) {
+            Point p1 = mv.getPoint(n1.eastNorth);
+            Point p2 = mv.getPoint(n2.eastNorth);
             if ((p1.x < 0) && (p2.x < 0)) return false;
             if ((p1.y < 0) && (p2.y < 0)) return false;
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/Coastlines.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/Coastlines.java	(revision 4821)
+++ applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/Coastlines.java	(revision 4843)
@@ -7,5 +7,4 @@
 
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.data.osm.Segment;
 import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.plugins.validator.Severity;
@@ -72,13 +71,5 @@
                     continue;
                 
-                int numSegments1 = w.segments.size();
-                Segment start1 = w.segments.get(0);
-                Segment end1 = numSegments1 > 1 ? w.segments.get(numSegments1 - 1) : start1;
-
-                int numSegments2 = w2.segments.size();
-                Segment start2 = w2.segments.get(0);
-                Segment end2 = numSegments2 > 1 ? w2.segments.get(numSegments2 - 1) : start2;
-                
-                if( start1.from.equals(start2.from) || end1.to.equals(end2.to))
+                if( w.nodes.get(0).equals(w2.nodes.get(0)) || w.nodes.get(w.nodes.size() - 1).equals(w2.nodes.get(w2.nodes.size() - 1)))
                 {
                     List<OsmPrimitive> primitives = new ArrayList<OsmPrimitive>();
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/CrossingSegments.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/CrossingSegments.java	(revision 4821)
+++ 	(revision )
@@ -1,184 +1,0 @@
-package org.openstreetmap.josm.plugins.validator.tests;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
-
-import java.awt.geom.Line2D;
-import java.awt.geom.Point2D;
-import java.util.*;
-
-import org.openstreetmap.josm.data.osm.*;
-import org.openstreetmap.josm.plugins.validator.*;
-import org.openstreetmap.josm.plugins.validator.util.Bag;
-import org.openstreetmap.josm.plugins.validator.util.Util;
-
-/**
- * Tests if there are segments that crosses in the same layer
- * 
- * @author frsantos
- */
-public class CrossingSegments extends Test 
-{
-	/** All segments, grouped by cells */
-	Map<Point2D,List<ExtendedSegment>> cellSegments;
-    /** The already detected errors */
-    Bag<Segment, Segment> errorSegments;
-	
-	/**
-	 * Constructor
-	 */
-	public CrossingSegments() 
-	{
-		super(tr("Crossing roads."),
-			  tr("This test checks if two roads,railways or waterways crosses in the same layer, but are not connected by a node."));
-	}
-
-
-	@Override
-	public void startTest() 
-	{
-		cellSegments = new HashMap<Point2D,List<ExtendedSegment>>(1000);
-        errorSegments = new Bag<Segment, Segment>();
-	}
-
-	@Override
-	public void endTest() 
-	{
-		cellSegments = null;
-		errorSegments = null;
-	}
-
-	@Override
-	public void visit(Way w) 
-	{
-        if( w.deleted )
-            return;
-        
-        String coastline1 = w.get("natural"); 
-        boolean isCoastline1 = coastline1 != null && (coastline1.equals("water") || coastline1.equals("coastline"));
-        String railway1 = w.get("railway"); 
-        boolean isSubway1 = railway1 != null && railway1.equals("subway");
-        if( w.get("highway") == null && w.get("waterway") == null && !isSubway1 && !isCoastline1) 
-        	return;
-        
-        String layer1 = w.get("layer");
-        for(Segment s : w.segments)
-        {
-        	if( s.incomplete )
-        		continue;
-        	
-            ExtendedSegment es1 = new ExtendedSegment(s, layer1, railway1, coastline1);
-            List<List<ExtendedSegment>> cellSegments = getSegments(s);
-            for( List<ExtendedSegment> segments : cellSegments)
-            {
-	            for( ExtendedSegment es2 : segments)
-	            {
-	            	if( errorSegments.contains(s, es2.s) || errorSegments.contains(es2.s, s))
-	            		continue;
-	            	
-	                String layer2 = es2.layer;
-	                String railway2 = es2.railway;
-	                String coastline2 = es2.coastline;
-	                if( (layer1 != null || layer2 != null) && (layer1 == null || !layer1.equals(layer2)) )
-	                	continue;
-	                
-	                if( !es1.intersects(es2) ) continue;
-		            if( isSubway1 && "subway".equals(railway2)) continue;
-		            
-		            boolean isCoastline2 = coastline2 != null && (coastline2.equals("water") || coastline2.equals("coastline"));
-	                if( isCoastline1 != isCoastline2 ) continue;
-	                
-                    List<OsmPrimitive> primitives = new ArrayList<OsmPrimitive>();
-                    primitives.add(es1.s);
-                    primitives.add(es2.s);
-                    errors.add( new TestError(this, Severity.WARNING, tr("Crossing roads"), primitives) );
-	            }
-	            segments.add(es1);
-            }
-        }
-	}
-	
-	/**
-     * Returns all the cells this segment crosses . Each cell contains the list
-     * of segments already processed
-     * 
-     * @param s The segment
-     * @return A list with all the cells the segment crosses.
-     */
-	public List<List<ExtendedSegment>> getSegments(Segment s)
-	{
-		List<List<ExtendedSegment>> cells = new ArrayList<List<ExtendedSegment>>();
-		for( Point2D cell : Util.getSegmentCells(s, 10000) )
-		{
-            List<ExtendedSegment> segments = cellSegments.get( cell );
-            if( segments == null )
-            {
-                segments = new ArrayList<ExtendedSegment>();
-                cellSegments.put(cell, segments);
-            }
-            cells.add(segments);
-        }
-        
-		return cells;
-	}
-    
-    /**
-     * A segment is a line with the formula "y = a*x+b"
-     * @author frsantos
-     */
-    class ExtendedSegment
-    {
-        /** The segment */
-        Segment s;
-        
-        /** The layer */
-        String layer;
-        
-        /** The railway type */
-		private String railway;
-
-		/** The coastline type */
-		private String coastline;
-        
-        /**
-         * Constructor
-         * @param s The segment
-         * @param layer The layer of the way this segment is in
-         * @param railway The railway type of the way this segment is in
-         * @param coastline The coastlyne typo of the way the segment is in
-         */
-        public ExtendedSegment(Segment s, String layer, String railway, String coastline)
-        {
-            this.s = s;
-            this.layer = layer;
-            this.railway = railway;
-            this.coastline = coastline;
-        }
-        
-        /**
-         * Checks whether this segment crosses other segment
-         * @param s2 The other segment
-         * @return true if both segements crosses
-         */
-        public boolean intersects(ExtendedSegment s2)
-        {
-        	Node n1From = this.s.from;
-			Node n1To = this.s.to;
-			Node n2From = s2.s.from;
-			Node n2To = s2.s.to;
-			if( n1From.equals(n2From) || n1To.equals(n2To) ||  
-        		n1From.equals(n2To)   || n1To.equals(n2From) )
-        	{
-                return false;
-        	}
-            
-    		return Line2D.linesIntersect(n1From.eastNorth.east(), 
-					    				 n1From.eastNorth.north(),
-					    				 n1To.eastNorth.east(),
-					    				 n1To.eastNorth.north(),
-					    				 n2From.eastNorth.east(),
-					    				 n2From.eastNorth.north(),
-					    				 n2To.eastNorth.east(),
-					    				 n2To.eastNorth.north());
-        }
-    }
-}
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/CrossingWays.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/CrossingWays.java	(revision 4843)
+++ applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/CrossingWays.java	(revision 4843)
@@ -0,0 +1,180 @@
+package org.openstreetmap.josm.plugins.validator.tests;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.util.*;
+
+import org.openstreetmap.josm.data.osm.*;
+import org.openstreetmap.josm.plugins.validator.*;
+import org.openstreetmap.josm.plugins.validator.util.Bag;
+import org.openstreetmap.josm.plugins.validator.util.Util;
+
+/**
+ * Tests if there are segments that crosses in the same layer
+ * 
+ * @author frsantos
+ */
+public class CrossingWays extends Test 
+{
+	/** All way segments, grouped by cells */
+	Map<Point2D,List<ExtendedSegment>> cellSegments;
+    /** The already detected errors */
+	HashSet<WaySegment> errorSegments;
+	
+	/**
+	 * Constructor
+	 */
+	public CrossingWays() 
+	{
+		super(tr("Crossing ways."),
+			  tr("This test checks if two roads, railways or waterways crosses in the same layer, but are not connected by a node."));
+	}
+
+
+	@Override
+	public void startTest() 
+	{
+		cellSegments = new HashMap<Point2D,List<ExtendedSegment>>(1000);
+        errorSegments = new HashSet<WaySegment>();
+	}
+
+	@Override
+	public void endTest() 
+	{
+		cellSegments = null;
+		errorSegments = null;
+	}
+
+	@Override
+	public void visit(Way w) 
+	{
+        if( w.deleted )
+            return;
+        
+        String coastline1 = w.get("natural"); 
+        boolean isCoastline1 = coastline1 != null && (coastline1.equals("water") || coastline1.equals("coastline"));
+        String railway1 = w.get("railway"); 
+        boolean isSubway1 = railway1 != null && railway1.equals("subway");
+        if( w.get("highway") == null && w.get("waterway") == null && !isSubway1 && !isCoastline1) 
+        	return;
+        
+        String layer1 = w.get("layer");
+
+		int nodesSize = w.nodes.size();
+		for (int i = 0; i < nodesSize - 1; i++) {
+			WaySegment ws = new WaySegment(w, i);
+            ExtendedSegment es1 = new ExtendedSegment(ws, layer1, railway1, coastline1);
+            List<List<ExtendedSegment>> cellSegments = getSegments(es1.n1, es1.n2);
+            for( List<ExtendedSegment> segments : cellSegments)
+            {
+	            for( ExtendedSegment es2 : segments)
+	            {
+					if (errorSegments.contains(ws) && errorSegments.contains(es2.ws))
+	            		continue;
+	            	
+	                String layer2 = es2.layer;
+	                String railway2 = es2.railway;
+	                String coastline2 = es2.coastline;
+					if (layer1 == null ? layer2 != null : !layer1.equals(layer2))
+	                	continue;
+	                
+	                if( !es1.intersects(es2) ) continue;
+		            if( isSubway1 && "subway".equals(railway2)) continue;
+		            
+		            boolean isCoastline2 = coastline2 != null && (coastline2.equals("water") || coastline2.equals("coastline"));
+	                if( isCoastline1 != isCoastline2 ) continue;
+	                
+                    List<OsmPrimitive> primitives = new ArrayList<OsmPrimitive>();
+                    primitives.add(es1.ws.way);
+                    primitives.add(es2.ws.way);
+                    errors.add( new TestError(this, Severity.WARNING, tr("Crossing ways"), primitives) );
+	            }
+	            segments.add(es1);
+            }
+        }
+	}
+	
+	/**
+     * Returns all the cells this segment crosses.  Each cell contains the list
+     * of segments already processed
+     * 
+     * @param n1 The first node.
+     * @param n2 The second node.
+     * @return A list with all the cells the segment crosses.
+     */
+	public List<List<ExtendedSegment>> getSegments(Node n1, Node n2)
+	{
+		List<List<ExtendedSegment>> cells = new ArrayList<List<ExtendedSegment>>();
+		for( Point2D cell : Util.getSegmentCells(n1, n2, 10000) )
+		{
+            List<ExtendedSegment> segments = cellSegments.get( cell );
+            if( segments == null )
+            {
+                segments = new ArrayList<ExtendedSegment>();
+                cellSegments.put(cell, segments);
+            }
+            cells.add(segments);
+        }
+        
+		return cells;
+	}
+    
+    /**
+     * A way segment with some additional information
+     * @author frsantos
+     */
+    private class ExtendedSegment
+    {
+		public Node n1, n2;
+
+		public WaySegment ws;
+        
+        /** The layer */
+        public String layer;
+        
+        /** The railway type */
+		public String railway;
+
+		/** The coastline type */
+		public String coastline;
+        
+        /**
+         * Constructor
+         * @param ws The way segment
+         * @param layer The layer of the way this segment is in
+         * @param railway The railway type of the way this segment is in
+         * @param coastline The coastlyne typo of the way the segment is in
+         */
+        public ExtendedSegment(WaySegment ws, String layer, String railway, String coastline)
+        {
+            this.ws = ws;
+			this.n1 = ws.way.nodes.get(ws.lowerIndex);
+			this.n2 = ws.way.nodes.get(ws.lowerIndex + 1);
+            this.layer = layer;
+            this.railway = railway;
+            this.coastline = coastline;
+        }
+        
+        /**
+         * Checks whether this segment crosses other segment
+         * @param s2 The other segment
+         * @return true if both segements crosses
+         */
+        public boolean intersects(ExtendedSegment s2)
+        {
+			if( n1.equals(s2.n1) || n2.equals(s2.n2) ||  
+        		n1.equals(s2.n2)   || n2.equals(s2.n1) )
+        	{
+                return false;
+        	}
+            
+    		return Line2D.linesIntersect(
+				n1.eastNorth.east(), n1.eastNorth.north(),
+				n2.eastNorth.east(), n2.eastNorth.north(),
+				s2.n1.eastNorth.east(), s2.n1.eastNorth.north(),
+				s2.n2.eastNorth.east(), s2.n2.eastNorth.north());
+        }
+    }
+}
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/DuplicateNode.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/DuplicateNode.java	(revision 4821)
+++ applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/DuplicateNode.java	(revision 4843)
@@ -113,59 +113,24 @@
             }
         }        
-        
-        // Since some segment may disappear, we need to track those too
-        Collection<OsmPrimitive> seglist = new ArrayList<OsmPrimitive>();
-                
-        // Now do the merging
+
         Collection<Command> cmds = new LinkedList<Command>();
-        for (final Segment s : Main.ds.segments) 
-        {
-            if( s.deleted || s.incomplete )
-                continue;
-            if( !nodes.contains( s.from ) && !nodes.contains( s.to ) )
-                continue;
-                
-            Segment newseg = new Segment(s);
-            if( nodes.contains( s.from ) )
-                newseg.from = target;
-            if( nodes.contains( s.to ) )
-                newseg.to = target;
 
-            // Is this node now a NULL node?
-            if( newseg.from == newseg.to )
-                seglist.add(s);
-            else
-                cmds.add(new ChangeCommand(s,newseg));
-        }
-        
-        if( seglist.size() > 0 )  // Some segments to be deleted?
-        {
-            // We really want to delete this, but we must check if it is part of a way first
-            for (final Way w : Main.ds.ways)
-            {
-                Way newway = null;
-                if( w.deleted )
-                    continue;
-                for (final OsmPrimitive o : seglist )
-                {
-                    Segment s = (Segment)o;
-                    if( w.segments.contains(s) )
-                    {
-                        if( newway == null )
-                            newway = new Way(w);
-                        newway.segments.remove(s);
-                    }
-                }
-                if( newway != null )   // Made changes?
-                {
-                    // If no segments left, delete the way
-                    if( newway.segments.size() == 0 )
-                        cmds.add(new DeleteCommand(Arrays.asList(new OsmPrimitive[]{w})));
-                    else
-                        cmds.add(new ChangeCommand(w,newway));
-                }
-            }
-            cmds.add(new DeleteCommand(seglist));
-        }
+		// Now search the ways for occurences of the nodes we are about to
+		// merge and replace them with the 'target' node
+		for (Way w : Main.ds.ways) {
+			if (w.deleted) continue;
+			// FIXME: use some fancy method from java.util.Collections and
+			// List.replace
+			Way wnew = null;
+			int len = w.nodes.size();
+			for (int i = 0; i < len; i++) {
+				if (!nodes.contains(w.nodes.get(i))) continue;
+				if (wnew == null) wnew = new Way(w);
+				wnew.nodes.set(i, target);
+			}
+			if (wnew != null) {
+				cmds.add(new ChangeCommand(w, wnew));
+			}
+		}
 
         cmds.add(new DeleteCommand(nodes));
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/DuplicateSegment.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/DuplicateSegment.java	(revision 4821)
+++ 	(revision )
@@ -1,98 +1,0 @@
-package org.openstreetmap.josm.plugins.validator.tests;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
-
-import java.util.List;
-
-import org.openstreetmap.josm.data.coor.LatLon;
-import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.data.osm.Segment;
-import org.openstreetmap.josm.plugins.validator.Severity;
-import org.openstreetmap.josm.plugins.validator.Test;
-import org.openstreetmap.josm.plugins.validator.TestError;
-import org.openstreetmap.josm.plugins.validator.util.Bag;
-/**
- * Tests if there are duplicate segments
- * 
- * @author frsantos
- */
-public class DuplicateSegment extends Test 
-{
-	/** Bag of all segments */
-	Bag<CompoundLatLon, OsmPrimitive> segments;
-	
-	/**
-	 * Constructor
-	 */
-	public DuplicateSegment() 
-	{
-		super(tr("Duplicated segments."),
-			  tr("This test checks that two nodes are not used by more than one segment."));
-		
-	}
-
-
-	@Override
-	public void startTest() 
-	{
-		segments = new Bag<CompoundLatLon, OsmPrimitive>(1000);
-	}
-
-	@Override
-	public void endTest() 
-	{
-		for(List<OsmPrimitive> duplicated : segments.values() )
-		{
-			if( duplicated.size() > 1)
-			{
-				errors.add( new TestError(this, Severity.ERROR, tr("Duplicated segments"), duplicated) );
-			}
-		}
-		segments = null;
-	}
-
-	@Override
-	public void visit(Segment s) 
-	{
-		if( !s.incomplete ) segments.add( new CompoundLatLon(s), s);
-	}
-	
-	/**
-	 * Compound LatLong for easy duplicity check
-	 * @author frsantos
-	 */
-	class CompoundLatLon
-	{
-		/** From position */
-		LatLon from;
-		/** To position */
-		LatLon to;
-		
-		/**
-		 * Constructor
-		 * @param s The segment
-		 */
-		public CompoundLatLon(Segment s)
-		{
-			this.from = s.from.coor;
-			this.to = s.to.coor;
-		}
-
-		@Override
-		public boolean equals(Object obj) 
-		{
-			if (obj == null || getClass() != obj.getClass() )
-				return super.equals(obj);
-			
-			CompoundLatLon other = (CompoundLatLon)obj;
-			return from.equals(other.from) && to.equals(other.to) ||
-				   to.equals(other.from) && from.equals(other.to);
-		}
-
-		@Override
-		public int hashCode() 
-		{
-			return from.hashCode() + to.hashCode();
-		}
-	}
-}
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/DuplicatedWayNodes.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/DuplicatedWayNodes.java	(revision 4843)
+++ applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/DuplicatedWayNodes.java	(revision 4843)
@@ -0,0 +1,59 @@
+package org.openstreetmap.josm.plugins.validator.tests;
+import static org.openstreetmap.josm.tools.I18n.tr;
+import org.openstreetmap.josm.plugins.validator.Test;
+import org.openstreetmap.josm.plugins.validator.TestError;
+import org.openstreetmap.josm.plugins.validator.Severity;
+import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.command.DeleteCommand;
+import org.openstreetmap.josm.command.ChangeCommand;
+import java.util.Collections;
+
+public class DuplicatedWayNodes extends Test {
+	public DuplicatedWayNodes() {
+		super(tr("Duplicated way nodes."),
+			tr("Checks for ways with identical consecutive nodes."));
+	}
+
+	@Override public void visit(Way w) {
+		if (w.deleted) return;
+
+		Node lastN = null;
+		for (Node n : w.nodes) {
+			if (lastN == null) {
+				lastN = n;
+				break;
+			}
+			if (lastN == n) {
+				errors.add(new TestError(this, Severity.ERROR, tr("Duplicated way nodes"), w));
+				break;
+			}
+			lastN = n;
+		}
+	}
+
+	@Override public Command fixError(TestError testError) {
+		Way w = (Way) testError.getPrimitives().iterator().next();
+		Way wnew = new Way(w);
+		wnew.nodes.clear();
+		Node lastN = null;
+		for (Node n : w.nodes) {
+			if (lastN == null) {
+				wnew.nodes.add(n);
+			} else if (n == lastN) {
+				// Skip this node
+			} else {
+				wnew.nodes.add(n);
+			}
+			lastN = n;
+		}
+		if (wnew.nodes.size() < 2) {
+			// Empty way, delete
+			return new DeleteCommand(Collections.singleton(w));
+		} else {
+			return new ChangeCommand(w, wnew);
+		}
+	}
+}
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/OrphanSegment.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/OrphanSegment.java	(revision 4821)
+++ 	(revision )
@@ -1,84 +1,0 @@
-package org.openstreetmap.josm.plugins.validator.tests;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
-
-import java.util.*;
-
-import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.data.osm.*;
-import org.openstreetmap.josm.plugins.validator.Severity;
-import org.openstreetmap.josm.plugins.validator.Test;
-import org.openstreetmap.josm.plugins.validator.TestError;
-
-/**
- * Check that every segment is in a way
- * 
- * @author frsantos
- */
-public class OrphanSegment extends Test 
-{
-	/** Bag of all nodes */
-	Set<Segment> segments;
-	
-	/**
-	 * Constructor
-	 */
-	public OrphanSegment() 
-	{
-		super(tr("Orphaned segments."),
-		      tr("This test checks that every segment is in a way."));
-	}
-
-
-	@Override
-	public void startTest() 
-	{
-		segments = new HashSet<Segment>(1000);
-	}
-
-	@Override
-	public void endTest() 
-	{
-		for(Segment segment : segments )
-		{
-			errors.add( new TestError(this, Severity.OTHER, tr("Segments not in a way"), segment) );
-		}
-		segments = null;
-	}
-
-    @Override
-    public void visit(Collection<OsmPrimitive> selection) 
-    {
-        // If there is a partial selection, it may be false positives if a
-        // segment is selected, but not the container way. So, in this
-        // case, we must visit all ways, selected or not.
-
-        for (OsmPrimitive p : selection)
-        {
-            if( !p.deleted )
-            {
-                if( !partialSelection || p instanceof Segment )
-                    p.visit(this);
-            }
-        }
-        
-        if( partialSelection )
-        {
-            for( Way w : Main.ds.ways)
-                visit(w);
-        }
-    }
-    
-	@Override
-	public void visit(Segment s) 
-	{
-        
-		segments.add(s);
-	}
-	
-	@Override
-	public void visit(Way w) 
-	{
-		segments.removeAll(w.segments);
-	}
-}
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/OverlappingWays.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/OverlappingWays.java	(revision 4843)
+++ applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/OverlappingWays.java	(revision 4843)
@@ -0,0 +1,75 @@
+package org.openstreetmap.josm.plugins.validator.tests;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.List;
+
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.NodePair;
+import org.openstreetmap.josm.plugins.validator.Severity;
+import org.openstreetmap.josm.plugins.validator.Test;
+import org.openstreetmap.josm.plugins.validator.TestError;
+import org.openstreetmap.josm.plugins.validator.util.Bag;
+
+/**
+ * Tests if there are overlapping ways
+ * 
+ * @author frsantos
+ */
+public class OverlappingWays extends Test 
+{
+	/** Bag of all way segments */
+	Bag<NodePair, OsmPrimitive> nodePairs;
+	
+	/**
+	 * Constructor
+	 */
+	public OverlappingWays() 
+	{
+		super(tr("Overlapping ways."),
+			  tr("This test checks that a connection between two nodes "
+				+ "is not used by more than one way."));
+		
+	}
+
+
+	@Override
+	public void startTest() 
+	{
+		nodePairs = new Bag<NodePair, OsmPrimitive>(1000);
+	}
+
+	@Override
+	public void endTest() 
+	{
+		for (List<OsmPrimitive> duplicated : nodePairs.values())
+		{
+			if (duplicated.size() > 1)
+			{
+				errors.add( new TestError(this, Severity.OTHER, tr("Overlapping ways"), duplicated) );
+			}
+		}
+		nodePairs = null;
+	}
+
+	@Override
+	public void visit(Way w) 
+	{
+		Node lastN = null;
+		for (Node n : w.nodes) {
+			if (lastN == null) {
+				lastN = n;
+				continue;
+			}
+			if (n.hashCode() > lastN.hashCode()) {
+				nodePairs.add(new NodePair(lastN, n), w);
+			} else {
+				nodePairs.add(new NodePair(n, lastN), w);
+			}
+			lastN = n;
+		}
+	}
+}
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/ReusedSegment.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/ReusedSegment.java	(revision 4821)
+++ 	(revision )
@@ -1,57 +1,0 @@
-package org.openstreetmap.josm.plugins.validator.tests;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
-
-import java.util.List;
-import java.util.Map;
-
-import org.openstreetmap.josm.data.osm.*;
-import org.openstreetmap.josm.plugins.validator.*;
-import org.openstreetmap.josm.plugins.validator.util.Bag;
-/**
- * Tests if there are duplicate segments
- * 
- * @author frsantos
- */
-public class ReusedSegment extends Test 
-{
-	/** Bag of all segments */
-	Bag<Segment, OsmPrimitive> segments;
-	
-	/**
-	 * Constructor
-	 */
-	public ReusedSegment() 
-	{
-		super(tr("Reused segments."),
-			  tr("This test checks if a segment is used in more than one way."));
-	}
-
-
-	@Override
-	public void startTest() 
-	{
-		segments = new Bag<Segment, OsmPrimitive>(1000);
-	}
-
-	@Override
-	public void endTest() 
-	{
-		for(Map.Entry<Segment, List<OsmPrimitive>> entry : segments.entrySet() )
-		{
-            Segment s = entry.getKey();
-			if( entry.getValue().size() > 1)
-			{
-				errors.add( new TestError(this, Severity.OTHER, tr("Reused segments"), s) );
-			}
-		}
-		segments = null;
-	}
-
-	@Override
-	public void visit(Way w) 
-	{
-        for( Segment s : w.segments)
-            if( !s.deleted ) segments.add( s, w );
-	}
-}
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/SingleNodeSegment.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/SingleNodeSegment.java	(revision 4821)
+++ 	(revision )
@@ -1,93 +1,0 @@
-package org.openstreetmap.josm.plugins.validator.tests;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.command.*;
-import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.data.osm.Segment;
-import org.openstreetmap.josm.data.osm.Way;
-import org.openstreetmap.josm.data.osm.visitor.CollectBackReferencesVisitor;
-import org.openstreetmap.josm.data.osm.visitor.NameVisitor;
-import org.openstreetmap.josm.plugins.validator.Severity;
-import org.openstreetmap.josm.plugins.validator.Test;
-import org.openstreetmap.josm.plugins.validator.TestError;
-
-/**
- * Checks that from/to nodes in a segment are different
- * 
- * @author frsantos
- */
-public class SingleNodeSegment extends Test 
-{
-	/** Tags allowed in a segment */
-	public static String[] allowedTags = new String[] { "created_by" };
-	
-	/**
-	 * Constructor
-	 */
-	public SingleNodeSegment() 
-	{
-		super(tr("Single node segments."),
-			  tr("This test checks that there are no segments with the same node as start and destination."));
-	}
-
-	@Override
-	public void visit(Segment s) 
-	{
-		if( !s.incomplete && s.from.equals(s.to) )
-		{
-			errors.add( new TestError(this, Severity.ERROR, tr("Single node segments"), s) );
-		}
-	}
-	
-	@Override
-	public Command fixError(TestError testError)
-	{
-		if( testError.getPrimitives().isEmpty() )
-			return null;
-		
-        Segment s = (Segment)testError.getPrimitives().get(0);
-        if( s.deleted )
-            return null;
-
-        List<Command> cmds = new ArrayList<Command>();
-        cmds.add(new DeleteCommand(testError.getPrimitives()));
-
-		CollectBackReferencesVisitor refV = new CollectBackReferencesVisitor(Main.ds);
-		s.visit(refV);
-
-		for(OsmPrimitive p : refV.data)
-        {
-            if( p.deleted )
-                continue;
-
-            Way newway = new Way((Way)p);
-            if( newway.segments.remove(s) ) // Made changes?
-            {
-                // If no segments left, delete the way
-                if( newway.segments.size() == 0 )
-                    cmds.add(new DeleteCommand(Arrays.asList(new OsmPrimitive[]{p})));
-                else
-                    cmds.add(new ChangeCommand(p, newway));
-            }
-        }
-		
-		if( cmds.size() == 1 ) // Segment wasn't in any way
-			return cmds.get(0);
-		
-		NameVisitor nameV = new NameVisitor();
-		s.visit(nameV);
-        return new SequenceCommand(tr("Delete")+" "+tr(nameV.className)+" "+nameV.name, cmds);
-	}
-	
-	@Override
-	public boolean isFixable(TestError testError)
-	{
-		return (testError.getTester() instanceof SingleNodeSegment);
-	}
-}
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/SpellCheck.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/SpellCheck.java	(revision 4821)
+++ applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/SpellCheck.java	(revision 4843)
@@ -207,11 +207,4 @@
 	{
 		checkPrimitive(n);
-	}
-
-
-	@Override
-	public void visit(Segment s) 
-	{
-		checkPrimitive(s);
 	}
 
@@ -460,5 +453,5 @@
         boolean checkFixmes = Main.pref.getBoolean(PREF_CHECK_FIXMES, true);
         prefCheckFixmes = new JCheckBox(tr("Check for FIXMES."), checkFixmes);
-        prefCheckFixmes.setToolTipText(tr("Looks for nodes, segments or ways with FIXME in any property value."));
+        prefCheckFixmes.setToolTipText(tr("Looks for nodes or ways with FIXME in any property value."));
         testPanel.add(prefCheckFixmes, GBC.std().insets(40,0,0,0));
 
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/TaggedSegment.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/TaggedSegment.java	(revision 4821)
+++ 	(revision )
@@ -1,88 +1,0 @@
-package org.openstreetmap.josm.plugins.validator.tests;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
-
-import java.util.*;
-
-import org.openstreetmap.josm.command.*;
-import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.data.osm.Segment;
-import org.openstreetmap.josm.plugins.validator.Severity;
-import org.openstreetmap.josm.plugins.validator.Test;
-import org.openstreetmap.josm.plugins.validator.TestError;
-
-/**
- * Check if a segment has tags
- * 
- * @author frsantos
- */
-public class TaggedSegment extends Test 
-{
-	/** Tags allowed in a segment */
-	public static String[] allowedTags = new String[] { "created_by", "converted_by", "source" };
-	
-	/**
-	 * Constructor
-	 */
-	public TaggedSegment() 
-	{
-		super(tr("Tagged segments"),
-			  tr("This test checks that no segment is tagged. Only ways should be tagged."));
-	}
-
-	@Override
-	public void visit(Segment s) 
-	{
-		Map<String, String> tags = s.keys;
-		if( tags == null )
-			return;
-		tags = new HashMap<String, String>(tags);
-		for( String tag : allowedTags)
-			tags.remove(tag);
-		
-		if( tags.size() > 0 )
-		{
-			errors.add( new TestError(this, Severity.WARNING, tr("Segments with tags"), s) );
-		}
-	}
-	
-	@Override
-	public Command fixError(TestError testError)
-	{
-		List<Command> commands = new ArrayList<Command>(50);
-		
-		int i = -1;
-		List<OsmPrimitive> primitives = testError.getPrimitives();
-		for(OsmPrimitive p : primitives )
-		{
-			i++;
-			Map<String, String> tags = p.keys;
-			if( tags == null )
-				continue;
-			
-			tags = new HashMap<String, String>(tags);
-			for( String tag : allowedTags)
-				tags.remove(tag);
-			
-			if( tags.size() == 0 )
-				continue;
-		
-			for(String key : tags.keySet() )
-			{
-				commands.add( new ChangePropertyCommand(primitives.subList(i, i+1), key, null) );
-			}
-		}
-		if( commands.size() == 0 )
-			return null;
-		else if( commands.size() == 1 )
-			return commands.get(0);
-		else
-			return new SequenceCommand("Remove keys", commands) ;
-	}
-	
-	@Override
-	public boolean isFixable(TestError testError)
-	{
-		return (testError.getTester() instanceof TaggedSegment);
-	}	
-}
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/UnorderedWay.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/UnorderedWay.java	(revision 4821)
+++ 	(revision )
@@ -1,57 +1,0 @@
-package org.openstreetmap.josm.plugins.validator.tests;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
-
-import org.openstreetmap.josm.actions.ReorderAction;
-import org.openstreetmap.josm.command.Command;
-import org.openstreetmap.josm.data.osm.*;
-import org.openstreetmap.josm.plugins.validator.*;
-
-/**
- * Check for unordered ways
- * 
- * @author frsantos
- */
-public class UnorderedWay extends Test 
-{
-	/**
-	 * Constructor
-	 */
-	public UnorderedWay() 
-	{
-		super(tr("Unordered ways."),
-			  tr("This test checks that all segments in a way are properly ordered."));
-	}
-
-	@Override
-	public void visit(Way w) 
-	{
-		Segment last = null;
-		for(Segment s: w.segments)
-		{
-			if( last != null && !last.incomplete && !s.incomplete && !last.to.equals(s.from) )
-			{
-				errors.add( new TestError(this, Severity.WARNING, tr("Unordered ways"), w) );
-				break;
-			}
-			last = s;
-		}
-	}
-	
-	@Override
-	public Command fixError(TestError testError)
-	{
-		for(OsmPrimitive p : testError.getPrimitives() )
-		{
-            return ReorderAction.reorderWay((Way)p);
-		}
-		
-		return null;
-	}
-	
-	@Override
-	public boolean isFixable(TestError testError)
-	{
-		return (testError.getTester() instanceof UnorderedWay);
-	}	
-}
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/UntaggedNode.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/UntaggedNode.java	(revision 4821)
+++ applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/UntaggedNode.java	(revision 4843)
@@ -9,11 +9,11 @@
 import org.openstreetmap.josm.command.DeleteCommand;
 import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.data.osm.Segment;
 import org.openstreetmap.josm.plugins.validator.Severity;
 import org.openstreetmap.josm.plugins.validator.Test;
 import org.openstreetmap.josm.plugins.validator.TestError;
 /**
- * Checks for untagged nodes that are in no segment
+ * Checks for untagged nodes that are in no way
  * 
  * @author frsantos
@@ -33,5 +33,5 @@
 	{
 		super(tr("Untagged nodes."),
-			  tr("This test checks for untagged nodes that are not part of any segment."));
+			  tr("This test checks for untagged nodes that are not part of any way."));
 	}
 
@@ -46,20 +46,21 @@
     {
 		// If there is a partial selection, it may be false positives if a
-		// node is selected, but not the container segment. So, in this
-		// case, we must visit all segments, selected or not.
-
-		for (OsmPrimitive p : selection)
-        {
-        	if( !p.deleted )
-        	{
-        		if( !partialSelection || p instanceof Node )
-        			p.visit(this);
-        	}
-        }
-        
-		if( partialSelection )
-		{
-			for( Segment s : Main.ds.segments)
-				visit(s);
+		// node is selected, but not the container way. So, in this
+		// case, we must visit all ways, selected or not.
+		if (partialSelection) {
+			for (OsmPrimitive p : selection) {
+				if (!p.deleted && p instanceof Node) {
+					p.visit(this);
+				}
+			}
+			for (Way w : Main.ds.ways) {
+				visit(w);
+			}
+		} else {
+			for (OsmPrimitive p : selection) {
+				if (!p.deleted) {
+					p.visit(this);
+				}
+			}
 		}
     }
@@ -84,8 +85,9 @@
 	
 	@Override
-	public void visit(Segment s) 
+	public void visit(Way w) 
 	{
-		emptyNodes.remove(s.from);
-		emptyNodes.remove(s.to);
+		for (Node n : w.nodes) {
+			emptyNodes.remove(n);
+		}
 	}
 	
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/UntaggedWay.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/UntaggedWay.java	(revision 4821)
+++ applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/UntaggedWay.java	(revision 4843)
@@ -87,5 +87,5 @@
         }
         
-        if( w.segments.size() == 0 )
+        if( w.nodes.size() == 0 )
         {
             errors.add( new TestError(this, Severity.ERROR, tr("Empty ways"), w, EMPTY_WAY) );
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/util/AgregatePrimitivesVisitor.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/util/AgregatePrimitivesVisitor.java	(revision 4821)
+++ applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/util/AgregatePrimitivesVisitor.java	(revision 4843)
@@ -11,6 +11,5 @@
  * A visitor that aggregates all primitives it visits.
  * <p>
- * The primitives are sorted according to their tyep: first Nodes, then
- * Segments, and Ways last.
+ * The primitives are sorted according to their tyep: first nodes, then ways.
  * 
  * @author frsantos
@@ -49,20 +48,13 @@
 	}
 
-	public void visit(Segment s) 
-	{
-		aggregatedData.add(s);
-		if( s.from != null ) visit(s.from);
-		if( s.to != null )   visit(s.to);
-	}
-
 	public void visit(Way w) 
 	{
 		aggregatedData.add(w);
-		for(Segment s : w.segments)
-			visit(s);
+		for (Node n : w.nodes)
+			visit(n);
 	}
 
 	/**
-	 * A comparator that orders Nodes first, then Segments and Ways last.
+	 * A comparator that orders nodes first, ways last.
 	 * 
 	 * @author frsantos
@@ -79,9 +71,5 @@
 			{
 				return o2 instanceof Way ? o1.hashCode() - o2.hashCode() : 1;
-			}
-			else // o1 is a segment
-			{
-				if( o2 instanceof Node ) return 1;
-				if( o2 instanceof Way ) return -1;
+			} else {
 				return o1.hashCode() - o2.hashCode();
 			}
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/util/Util.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/util/Util.java	(revision 4821)
+++ applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/util/Util.java	(revision 4843)
@@ -13,6 +13,6 @@
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.data.osm.Segment;
 import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.plugins.*;
 import org.openstreetmap.josm.plugins.validator.PreferenceEditor;
@@ -242,17 +242,9 @@
     public static List<List<Way>> getWaysInCell(Way w, Map<Point2D,List<Way>> cellWays)
     {
-        int numSegments = w.segments.size();
-        if( numSegments == 0)
+		if (w.nodes.size() == 0)
             return Collections.emptyList();
 
-        Segment start = w.segments.get(0);
-        Segment end = start;
-        if( numSegments > 1 )
-        {
-            end = w.segments.get(numSegments - 1);
-        }
-        
-        if( start.incomplete || end.incomplete )
-            return Collections.emptyList();
+		Node n1 = w.nodes.get(0);
+		Node n2 = w.nodes.get(w.nodes.size() - 1);
         
         List<List<Way>> cells = new ArrayList<List<Way>>(2);
@@ -261,8 +253,8 @@
 
         // First, round coordinates
-        long x0 = Math.round(start.from.eastNorth.east()  * 10000);
-        long y0 = Math.round(start.from.eastNorth.north() * 10000);
-        long x1 = Math.round(end.to.eastNorth.east()      * 10000);
-        long y1 = Math.round(end.to.eastNorth.north()     * 10000);
+        long x0 = Math.round(n1.eastNorth.east()  * 10000);
+        long y0 = Math.round(n1.eastNorth.north() * 10000);
+        long x1 = Math.round(n2.eastNorth.east()  * 10000);
+        long y1 = Math.round(n2.eastNorth.north() * 10000);
 
         // Start of the way
@@ -292,8 +284,8 @@
 
         // Then floor coordinates, in case the way is in the border of the cell.
-        x0 = (long)Math.floor(start.from.eastNorth.east()  * 10000);
-        y0 = (long)Math.floor(start.from.eastNorth.north() * 10000);
-        x1 = (long)Math.floor(end.to.eastNorth.east()      * 10000);
-        y1 = (long)Math.floor(end.to.eastNorth.north()     * 10000);
+        x0 = (long)Math.floor(n1.eastNorth.east()  * 10000);
+        y0 = (long)Math.floor(n1.eastNorth.north() * 10000);
+        x1 = (long)Math.floor(n2.eastNorth.east()  * 10000);
+        y1 = (long)Math.floor(n2.eastNorth.north() * 10000);
 
         // Start of the way
@@ -329,17 +321,20 @@
     
     /**
-	 * Returns the coordinates of all cells in a grid that a segment goes through.
+	 * Returns the coordinates of all cells in a grid that a line between 2
+	 * nodes intersects with.
 	 * 
-	 * @param s The segment
-	 * @param gridDetail The detail of the grid. Bigger values give smaller cells, but a bigger number of them.
+	 * @param n1 The first node.
+	 * @param n2 The second node.
+	 * @param gridDetail The detail of the grid. Bigger values give smaller
+	 * cells, but a bigger number of them.
 	 * @return A list with the coordinates of all cells
 	 */
-	public static List<Point2D> getSegmentCells(Segment s, int gridDetail) 
+	public static List<Point2D> getSegmentCells(Node n1, Node n2, int gridDetail) 
 	{
 		List<Point2D> cells = new ArrayList<Point2D>();
-		double x0 = s.from.eastNorth.east() * gridDetail;
-		double x1 = s.to.eastNorth.east()   * gridDetail;
-        double y0 = s.from.eastNorth.north()* gridDetail + 1;
-        double y1 = s.to.eastNorth.north()  * gridDetail + 1;
+		double x0 = n1.eastNorth.east() * gridDetail;
+		double x1 = n2.eastNorth.east() * gridDetail;
+        double y0 = n1.eastNorth.north() * gridDetail + 1;
+        double y1 = n2.eastNorth.north() * gridDetail + 1;
 
         if( x0 > x1 )
