Index: src/uk/me/parabola/mkgmap/filters/LineMergeFilter.java
===================================================================
--- src/uk/me/parabola/mkgmap/filters/LineMergeFilter.java	(revision 2598)
+++ src/uk/me/parabola/mkgmap/filters/LineMergeFilter.java	(working copy)
@@ -13,6 +13,8 @@
 public class LineMergeFilter{
 	private static final Logger log = Logger.getLogger(LineMergeFilter.class);
 
+	private static final double MAX_BEARING_DIFF = 30;
+
 	private List<MapLine> linesMerged;
 	private final MultiHashMap<Coord, MapLine> startPoints = new MultiHashMap<Coord, MapLine>();
 	private final MultiHashMap<Coord, MapLine> endPoints = new MultiHashMap<Coord, MapLine>();
@@ -56,6 +58,8 @@
 	public List<MapLine> merge(List<MapLine> lines, boolean skipRoads) {
 		linesMerged = new ArrayList<MapLine>(lines.size());	//better use LinkedList??
 		for (MapLine line : lines) {
+			if (line.getPoints().size() < 2)
+				continue;
 			
 			if (skipRoads && line.isRoad()){
 				linesMerged.add(line);
@@ -68,9 +72,13 @@
 			Coord end = points.get(points.size()-1); 
 
 			// Search for start point in hashlist 
-			// (can the end of current line connected to an existing line?)
+			// (can the end of current line be connected to an existing line?)
 			for (MapLine line2 : startPoints.get(end)) {
 				if (line.isSimilar(line2)) {
+					if (line.isDirection()){
+						if (Math.abs(line.getLastBearing() - line2.getFirstBearing()) > MAX_BEARING_DIFF)
+							continue;
+					}
 					addPointsAtStart(line2, points);
 					// Search for endpoint in hashlist
 					// (if the other end (=start of line =start of line2) could be connected to an existing line,
@@ -79,6 +87,10 @@
 						if (line2.isSimilar(line1)
 						 && !line2.equals(line1)) // don't make a closed loop a double loop
 						{
+							if (line2.isDirection()){
+								if (Math.abs(line1.getLastBearing() - line2.getFirstBearing()) > MAX_BEARING_DIFF)
+									continue;
+						}
 							mergeLines(line1, line2);
 							break;
 						}
@@ -91,9 +103,13 @@
 				continue;
 
 			// Search for endpoint in hashlist
-			// (can the start of current line connected to an existing line?)
+			// (can the start of current line be connected to an existing line?)
 			for (MapLine line2 : endPoints.get(start)) {
 				if (line.isSimilar(line2)) {
+					if (line.isDirection()){
+						if (Math.abs(line2.getLastBearing() - line.getFirstBearing()) > MAX_BEARING_DIFF)
+							continue;
+					}
 					addPointsAtEnd(line2, points);
 					isMerged = true;
 					break;
Index: src/uk/me/parabola/mkgmap/general/MapLine.java
===================================================================
--- src/uk/me/parabola/mkgmap/general/MapLine.java	(revision 2606)
+++ src/uk/me/parabola/mkgmap/general/MapLine.java	(working copy)
@@ -30,7 +30,7 @@
  */
 public class MapLine extends MapElement {
 	private static final Logger log = Logger.getLogger(MapLine.class);
-
+	//public long osmid;
 	private List<Coord> points;
 	private boolean direction; // set if direction is important.
 	private int minLat = Integer.MAX_VALUE;
@@ -44,6 +44,7 @@
 	public MapLine(MapLine orig) {
 		super(orig);
 		direction = orig.direction;
+		//osmid = orig.osmid;
 		//roadDef = orig.roadDef;
 	}
 
@@ -62,10 +63,10 @@
 		assert !points.isEmpty() : "trying to set points with zero length";
 
 		this.points = points;
-		testForConsecutivePoints(points);
+		updateBounds(points);
 	}
 	
-	public void testForConsecutivePoints(List<Coord> points) {
+	private void updateBounds(List<Coord> points) {
 		Coord last = null;
 		for (Coord co : points) {
 			if (last != null && last.equals(co))
@@ -78,14 +79,14 @@
 	}
 
 	public void insertPointsAtStart(List<Coord> additionalPoints) {
-		testForConsecutivePoints(additionalPoints);
+		updateBounds(additionalPoints);
 		points.get(0).preserved(true);
 		points.addAll(0, additionalPoints);
 		points.remove(additionalPoints.size()-1);	//End node exists now twice
 	}
 
 	public void insertPointsAtEnd(List<Coord> additionalPoints) {
-		testForConsecutivePoints(additionalPoints);
+		updateBounds(additionalPoints);
 		additionalPoints.get(0).preserved(true);
 		points.remove(points.size()-1); 
 		points.addAll(additionalPoints);
@@ -143,4 +144,47 @@
 		return new Area(minLat, minLong, maxLat, maxLong);
 	}
 
+	public boolean isSimilar(MapLine other){
+		if (direction != other.direction)
+			return false;
+		return isSimilar((MapElement) other);
+	}
+
+	/**
+	 * @return the bearing of the segment or 0 if line has less than two points  
+	 */
+	public double getFirstBearing(){
+		int nMax = points.size();
+		if (nMax < 2)
+			return 0;
+		Coord p0 = points.get(0);
+		Coord p1 = p0;
+		for (int n = 1; n < nMax; n++ ){
+			p1 = points.get(n);
+			if (p1.equals(p0) == false)
+				break;
+		}
+		if (p1.equals(p0) )
+			return 0;
+		return p0.bearingTo(p1);
+	}
+	
+	/**
+	 * @return the bearing of the last segment or 0 if line has less than two points  
+	 */
+	public double getLastBearing(){
+		int nMax = points.size();
+		if (nMax < 2)
+			return 0;
+		Coord p1 = points.get(nMax - 1);
+		Coord p0 = p1;
+		for (int n = nMax-2; n >= 0; n-- ){
+			p0 = points.get(n);
+			if (p1.equals(p0) == false)
+				break;
+		}
+		if (p1.equals(p0) )
+			return 0;
+		return p0.bearingTo(p1);
+	}
 }
Index: src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(revision 2599)
+++ src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(working copy)
@@ -242,6 +242,7 @@
 		if (foundType.getFeatureKind() == FeatureKind.POLYLINE) {
 		    if(foundType.isRoad() &&
 			   !MapObject.hasExtendedType(foundType.getType())){
+		    	checkOnewayDirection(way);
 		    	roads.add(way);
 		    	roadTypes.add(new GType(foundType));
 		    }
@@ -254,6 +255,19 @@
 			addShape(way, foundType);
 	}
 
+	private void checkOnewayDirection(Way way) {
+		String oneWay = way.getTag("oneway");
+		if("-1".equals(oneWay) || "reverse".equals(oneWay)) {
+			// it's a oneway street in the reverse direction
+			// so reverse the order of the nodes and change
+			// the oneway tag to "yes"
+			way.reverse();
+			way.addTag("oneway", "yes");
+			if("roundabout".equals(way.getTag("junction")))
+				log.warn("Roundabout " + way.getId() + " has reverse oneway tag (" + way.getPoints().get(0).toOSMURL() + ")");
+		}
+	}
+
 	/**
 	 * Takes a node (that has its own identity) and converts it from the OSM
 	 * type to the Garmin map type.
@@ -494,6 +508,7 @@
 
 	private void addLine(Way way, GType gt, List<Coord> points) {
 		MapLine line = new MapLine();
+//		line.osmid = way.getId();
 		elementSetup(line, gt, way);
 		line.setPoints(points);
 
@@ -695,16 +710,6 @@
 
 	void addRoad(Way way, GType gt) {
 
-		String oneWay = way.getTag("oneway");
-		if("-1".equals(oneWay) || "reverse".equals(oneWay)) {
-			// it's a oneway street in the reverse direction
-			// so reverse the order of the nodes and change
-			// the oneway tag to "yes"
-			way.reverse();
-			way.addTag("oneway", "yes");
-			if("roundabout".equals(way.getTag("junction")))
-				log.warn("Roundabout " + way.getId() + " has reverse oneway tag (" + way.getPoints().get(0).toOSMURL() + ")");
-		}
 
 		if("roundabout".equals(way.getTag("junction"))) {
 			List<Coord> points = way.getPoints();
@@ -1369,7 +1374,10 @@
 		line.setPoints(points);
 
 		MapRoad road = new MapRoad(way.getId(), line);
-
+		if ( way.getId() == 6971216){
+			long dd = 4;
+		}
+//		road.osmid = way.getId();
 		boolean doFlareCheck = true;
 		if("roundabout".equals(way.getTag("junction"))) {
 			road.setRoundabout(true);
