Index: src/uk/me/parabola/mkgmap/build/MapBuilder.java
===================================================================
--- src/uk/me/parabola/mkgmap/build/MapBuilder.java	(revision 2570)
+++ src/uk/me/parabola/mkgmap/build/MapBuilder.java	(working copy)
@@ -105,6 +105,7 @@
 	private final java.util.Map<MapPoint,City> cityMap = new HashMap<MapPoint,City>();
 
 	private boolean doRoads;
+	private boolean routingErrorMsgPrinted;
 
 	private Locator locator;
 
@@ -1097,6 +1098,7 @@
 		private final Subdivision div;
 		private final Map map;
 		private final boolean doRoads;
+		
 
 		LineAddFilter(Subdivision div, Map map, boolean doRoads) {
 			this.div = div;
@@ -1123,16 +1125,21 @@
 			pl.addCoords(line.getPoints());
 
 			pl.setType(line.getType());
+			if (doRoads){
+				if (line.isRoad()) {
+					if (log.isDebugEnabled())
+						log.debug("adding road def: " + line.getName());
+					RoadDef roaddef = ((MapRoad) line).getRoadDef();
 
-			if (doRoads && line.isRoad()) {
-				if (log.isDebugEnabled())
-					log.debug("adding road def: " + line.getName());
-				RoadDef roaddef = ((MapRoad) line).getRoadDef();
-
-				pl.setRoadDef(roaddef);
-				roaddef.addPolylineRef(pl);
+					pl.setRoadDef(roaddef);
+					roaddef.addPolylineRef(pl);
+				} else if (routingErrorMsgPrinted == false){
+					if (line.getMaxResolution() == 24 && (line.getType() >= 0x01 && line.getType() <= 0x13 || line.getType() == 0x1a || line.getType() == 0x1b)){
+						log.error("Non-routable way with routable type " + String.format("0x%x", line.getType()) + " is used for a routable map. This leads to routing errors. Use --list-styles to check the style.");
+						routingErrorMsgPrinted = true;
+					}
+				}
 			}
-
 			map.addMapObject(pl);
 		}
 	}
Index: src/uk/me/parabola/mkgmap/main/Main.java
===================================================================
--- src/uk/me/parabola/mkgmap/main/Main.java	(revision 2570)
+++ src/uk/me/parabola/mkgmap/main/Main.java	(working copy)
@@ -302,15 +302,16 @@
 		System.out.println("The following styles are available:");
 		for (String name : names) {
 			Style style;
+			boolean performChecks = "classpath:styles".equals(styleFile) && ("default".equals(name) == false) ? false : true;
 			try {
-				style = new StyleImpl(styleFile, name);
+				style = new StyleImpl(styleFile, name, performChecks);
 			} catch (SyntaxException e) {
 				System.err.println("Error in style: " + e.getMessage());
 				continue;
 			} catch (FileNotFoundException e) {
 				log.debug("could not find style", name);
 				try {
-					style = new StyleImpl(styleFile, null);
+					style = new StyleImpl(styleFile, null, performChecks);
 				} catch (SyntaxException e1) {
 					System.err.println("Error in style: " + e1.getMessage());
 					continue;
Index: src/uk/me/parabola/mkgmap/osmstyle/OverlayReader.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/OverlayReader.java	(revision 2570)
+++ src/uk/me/parabola/mkgmap/osmstyle/OverlayReader.java	(working copy)
@@ -122,4 +122,10 @@
 			adder.add(line);
 		}
 	}
+
+	public Map<Integer, List<Integer>> getOverlays() {
+		return overlays;
+	}
+	
+
 }
Index: src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java	(revision 2570)
+++ src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java	(working copy)
@@ -19,7 +19,8 @@
 import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.Reader;
-
+import java.util.List;
+import java.util.Map;
 import uk.me.parabola.log.Logger;
 import uk.me.parabola.mkgmap.general.LevelInfo;
 import uk.me.parabola.mkgmap.osmstyle.actions.ActionList;
@@ -74,10 +75,25 @@
 	 */
 	public void load(StyleFileLoader loader, String name) throws FileNotFoundException {
 		this.loader = loader;
-		load(loader.open(name), name);
+		load(loader.open(name), name, false, null);
 	}
 
-	private void load(Reader r, String name) {
+	
+	/**
+	 * Read a rules file.
+	 * @param loader A file loader.
+	 * @param name The name of the file to open.
+	 * @param performChecks if true, report potential errors 
+	 * @param overlays a map with overlays or null
+	 * @throws FileNotFoundException If the given file does not exist.
+	 */
+	public void load(StyleFileLoader loader, String name, boolean performChecks, Map<Integer, List<Integer>> overlays) throws FileNotFoundException {
+		this.loader = loader;
+		load(loader.open(name), name, performChecks, overlays);
+	}
+
+	
+	private void load(Reader r, String name, boolean performChecks, Map<Integer, List<Integer>> overlays) {
 		scanner = new TokenScanner(name, r);
 		scanner.setExtraWordChars("-:.");
 
@@ -100,7 +116,7 @@
 			// If there is an action list, then we don't need a type
 			GType type = null;
 			if (scanner.checkToken("["))
-				type = typeReader.readType(scanner);
+				type = typeReader.readType(scanner, performChecks, overlays);
 			else if (actionList == null)
 				throw new SyntaxException(scanner, "No type definition given");
 
@@ -483,7 +499,7 @@
 			RuleSet rs = new RuleSet();
 			RuleFileReader rr = new RuleFileReader(FeatureKind.POLYLINE,
 					LevelInfo.createFromString("0:24 1:20 2:18 3:16 4:14"), rs);
-			rr.load(r, "string");
+			rr.load(r, "string", true,null);
 			System.out.println("Result: " + rs);
 		} else {
 			System.err.println("Usage: RuleFileReader <file>");
Index: src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(revision 2570)
+++ src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(working copy)
@@ -155,7 +155,7 @@
 		public void add(MapLine element) {
 			if (element instanceof MapRoad)
 				collector.addRoad((MapRoad) element);
-			else
+			else 
 				collector.addLine(element);
 		}
 	};
@@ -1771,7 +1771,7 @@
 
 	/**
 	 * Detect roads that do not share any node with another road.
-	 * If such a road has the mkgmap:check_connected=true tag, add it as line, not as a road. 
+	 * If such a road has the mkgmap:set_unconnected_type tag, add it as line, not as a road. 
 	 */
 	private void findUnconnectedRoads(){
 		
@@ -1797,7 +1797,8 @@
 		// find roads that are not connected
 		for (int i = 0; i < roads.size(); i++){
 			Way way = roads.get(i);
-			if ("true".equals(way.getTag("mkgmap:check_connected"))){
+			String check_type = way.getTag("mkgmap:set_unconnected_type");
+			if (check_type != null){
 				boolean isConnected = false;
 				boolean onBoundary = false;
 				for (Coord p:way.getPoints()){
@@ -1814,10 +1815,20 @@
 				if (!isConnected){
 					if (onBoundary){
 						log.info("road not connected to other roads but is on boundary: " + way.toBrowseURL());
-						
 					} else {
-						log.info("road not connected to other roads, added as line: " + way.toBrowseURL());
-						addLine(way, roadTypes.get(i));
+						int type = 0;
+						try{
+							type = Integer.decode(check_type);
+						} catch (NumberFormatException e){
+							log.warn("invalid type value in mkgmap:set_unconnected_type: " + check_type);
+						}
+						if (type != 0){
+							log.info("road not connected to other roads, added as line with type " + check_type + ": " + way.toBrowseURL());
+							GType gt = new GType(roadTypes.get(i), check_type); 
+							addLine(way, gt);
+						} else {
+							log.warn("road not connected to other roads, but no replacement type found. Dropped: " + way.toBrowseURL());
+						}
 						roads.set(i, null);
 					}
 				}
Index: src/uk/me/parabola/mkgmap/osmstyle/StyleImpl.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/StyleImpl.java	(revision 2570)
+++ src/uk/me/parabola/mkgmap/osmstyle/StyleImpl.java	(working copy)
@@ -38,6 +38,7 @@
 import java.util.Set;
 import java.util.regex.Pattern;
 
+import uk.me.parabola.imgfmt.ExitException;
 import uk.me.parabola.imgfmt.Utils;
 import uk.me.parabola.log.Logger;
 import uk.me.parabola.mkgmap.Option;
@@ -73,6 +74,9 @@
 public class StyleImpl implements Style {
 	private static final Logger log = Logger.getLogger(StyleImpl.class);
 
+	public static final boolean WITH_CHECKS = true; 
+	public static final boolean WITHOUT_CHECKS = false;
+	
 	// This is max the version that we understand
 	private static final int VERSION = 1;
 
@@ -118,7 +122,9 @@
 	private final RuleSet relations = new RuleSet();
 
 	private OverlayReader overlays;
-
+	private final boolean performChecks;
+	
+	
 	/**
 	 * Create a style from the given location and name.
 	 * @param loc The location of the style. Can be null to mean just check
@@ -128,10 +134,25 @@
 	 * @throws FileNotFoundException If the file doesn't exist.  This can
 	 * include the version file being missing.
 	 */
-	public StyleImpl(String loc, String name) throws FileNotFoundException {
+	public StyleImpl(String styleFile, String name) throws FileNotFoundException {
+		this(styleFile,name,WITHOUT_CHECKS);
+	}
+	
+	/**
+	 * Create a style from the given location and name.
+	 * @param loc The location of the style. Can be null to mean just check
+	 * the classpath.
+	 * @param name The name.  Can be null if the location isn't.  If it is
+	 * null then we just check for the first version file that can be found.
+	 * @throws FileNotFoundException If the file doesn't exist.  This can
+	 * include the version file being missing.
+	 */
+	public StyleImpl(String loc, String name, boolean performChecks) throws FileNotFoundException {
 		location = loc;
 		fileLoader = StyleFileLoader.createStyleLoader(loc, name);
 
+		this.performChecks = performChecks;
+		
 		// There must be a version file, if not then we don't create the style.
 		checkVersion();
 
@@ -144,9 +165,11 @@
 			mergeOptions(baseStyle);
 
 		readOptions();
+		// read overlays before the style rules to be able to ignore overlaid "wrong" types. 
+		readOverlays(); 
+		
 		readRules();
 
-		readOverlays();
 
 		readMapFeatures();
 
@@ -294,7 +317,7 @@
 
 		try {
 			RuleFileReader reader = new RuleFileReader(FeatureKind.RELATION, levels, relations);
-			reader.load(fileLoader, "relations");
+			reader.load(fileLoader, "relations", performChecks, getOverlaidTypeMap());
 		} catch (FileNotFoundException e) {
 			// it is ok for this file to not exist.
 			log.debug("no relations file");
@@ -302,7 +325,7 @@
 
 		try {
 			RuleFileReader reader = new RuleFileReader(FeatureKind.POINT, levels, nodes);
-			reader.load(fileLoader, "points");
+			reader.load(fileLoader, "points", performChecks, getOverlaidTypeMap());
 		} catch (FileNotFoundException e) {
 			// it is ok for this file to not exist.
 			log.debug("no points file");
@@ -310,14 +333,14 @@
 
 		try {
 			RuleFileReader reader = new RuleFileReader(FeatureKind.POLYLINE, levels, lines);
-			reader.load(fileLoader, "lines");
+			reader.load(fileLoader, "lines", performChecks, getOverlaidTypeMap());
 		} catch (FileNotFoundException e) {
 			log.debug("no lines file");
 		}
 
 		try {
 			RuleFileReader reader = new RuleFileReader(FeatureKind.POLYGON, levels, polygons);
-			reader.load(fileLoader, "polygons");
+			reader.load(fileLoader, "polygons", performChecks, getOverlaidTypeMap());
 		} catch (FileNotFoundException e) {
 			log.debug("no polygons file");
 		}
@@ -512,7 +535,7 @@
 			return;
 
 		try {
-			baseStyles.add(new StyleImpl(location, name));
+			baseStyles.add(new StyleImpl(location, name, performChecks));
 		} catch (SyntaxException e) {
 			System.err.println("Error in style: " + e.getMessage());
 		} catch (FileNotFoundException e) {
@@ -522,7 +545,7 @@
 			log.debug("could not open base style file", e);
 
 			try {
-				baseStyles.add(new StyleImpl(null, name));
+				baseStyles.add(new StyleImpl(null, name, performChecks));
 			} catch (SyntaxException se) {
 				System.err.println("Error in style: " + se.getMessage());
 			} catch (FileNotFoundException e1) {
@@ -610,13 +633,52 @@
 		stylePrinter.dumpToFile(out);
 	}
 
+	/**
+	 * 
+	 * @return null or the map that was read from the overlays file
+	 */
+	private Map<Integer, List<Integer>> getOverlaidTypeMap() {
+		if (overlays != null)
+			return overlays.getOverlays();
+		return Collections.emptyMap();
+	}
+
+	/**
+	 * Evaluate the style options and try to read the style.
+	 * @param props the program properties
+	 * @return A style instance or null in case of error. 
+	 */
+	public static Style readStyle(Properties props) {
+		String loc = props.getProperty("style-file");
+		if (loc == null)
+			loc = props.getProperty("map-features");
+		String name = props.getProperty("style");
+
+		if (loc == null && name == null)
+			name = "default";
+
+		Style style = null;
+		try {
+			style = new StyleImpl(loc, name);
+			style.applyOptionOverride(props);
+		} catch (SyntaxException e) {
+			System.err.println("Error in style: " + e.getMessage());
+			throw new ExitException("Could not open style " + name);
+		} catch (FileNotFoundException e) {
+			String name1 = (name != null)? name: loc;
+			throw new ExitException("Could not open style " + name1);
+		}
+		return style;
+	}
+	
 	public static void main(String[] args) throws FileNotFoundException {
 		String file = args[0];
 		String name = null;
 		if (args.length > 1)
 			name = args[1];
-		StyleImpl style = new StyleImpl(file, name);
+		StyleImpl style = new StyleImpl(file, name, WITH_CHECKS);
 
 		style.dumpToFile(new OutputStreamWriter(System.out));
 	}
+
 }
Index: src/uk/me/parabola/mkgmap/osmstyle/TypeReader.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/TypeReader.java	(revision 2570)
+++ src/uk/me/parabola/mkgmap/osmstyle/TypeReader.java	(working copy)
@@ -1,5 +1,8 @@
 package uk.me.parabola.mkgmap.osmstyle;
 
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
 import java.util.regex.Pattern;
 
 import uk.me.parabola.log.Logger;
@@ -26,7 +29,11 @@
 		this.levels = levels;
 	}
 
-	public GType readType(TokenScanner ts) {
+	public GType readType(TokenScanner ts){
+		return readType(ts, false, null);
+	}
+	
+	public GType readType(TokenScanner ts, boolean performChecks, Map<Integer, List<Integer>> overlays) {
 		// We should have a '[' to start with
 		Token t = ts.nextToken();
 		if (t == null || t.getType() == TokType.EOF)
@@ -42,8 +49,8 @@
 			throw new SyntaxException(ts, "Garmin type number must be first.  Saw '" + type + '\'');
 
 		log.debug("gtype", type);
+
 		GType gt = new GType(kind, type);
-
 		while (!ts.isEndOfFile()) {
 			ts.skipSpace();
 			String w = ts.nextValue();
@@ -80,6 +87,55 @@
 		}
 
 		gt.fixLevels(levels);
+		if (performChecks){
+			boolean fromOverlays = false;
+			List<Integer> usedTypes = null;
+			if (overlays != null){
+				usedTypes = overlays.get(gt.getType());
+				if (usedTypes != null)
+					fromOverlays = true;
+			}
+			if (usedTypes == null)
+				usedTypes = Arrays.asList(gt.getType());
+			for (int i = 0; i < usedTypes.size(); i++){
+				int usedType = usedTypes.get(i);
+				boolean isOk = true;
+				if (usedType >= 0x010000){
+					if ((usedType & 0xff) > 0x1f)
+						isOk = false;
+				} else {
+					if (kind == FeatureKind.POLYLINE && usedType > 0x3f)
+						isOk = false;
+					else if (kind == FeatureKind.POLYGON && usedType> 0x7f)
+						isOk = false;
+					else if (kind == FeatureKind.POINT){
+						if (usedType < 0x0100 || (usedType & 0x00ff) > 0x1f) 
+							isOk = false;
+					}
+				}
+				if (!isOk){
+					String msg = "Warning: invalid type " + type + " for " + kind + " in style file " + ts.getFileName() + ", line " + ts.getLinenumber();
+					if (fromOverlays)
+						msg += ". Type is overlaid with " + String.format("0x%x", usedType);
+					System.out.println(msg);
+				}
+				if (kind == FeatureKind.POLYLINE && gt.getMaxResolution() == 24 && (usedType >= 0x01 && usedType <= 0x13 || usedType == 0x1a || usedType == 0x1b)){
+					if (gt.isRoad() == false){
+						String msg = "Warning: routable type " + type  + " is used for non-routable line with resolution 24. This may break routing. Style file "+ ts.getFileName() + ", line " + ts.getLinenumber();
+						if (fromOverlays)
+							msg += ". Type is overlaid with " + String.format("0x%x", usedType);
+						System.err.println(msg);
+					}
+					else if (i > 0){
+						System.out.println("Warning: routable type " + type + " is used for non-routable line with resolution 24. " +
+								"This may break routing. Style file " + ts.getFileName() + ", line " + ts.getLinenumber() + 
+								". Type is overlaid with " + String.format("0x%x", usedType) + 
+								" which is used for adding the non-routable copy of the way.");
+					}
+				}
+			}
+		}
+		
 		return gt;
 	}
 
Index: src/uk/me/parabola/mkgmap/reader/osm/GType.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/GType.java	(revision 2570)
+++ src/uk/me/parabola/mkgmap/reader/osm/GType.java	(working copy)
@@ -61,7 +61,7 @@
 			this.type = Integer.decode(type);
 		} catch (NumberFormatException e) {
 			log.error("not numeric " + type);
-			throw new ExitException("non-numeric type in map-features file");
+			throw new ExitException("non-numeric type in style file");
 		}
 	}
 
@@ -89,6 +89,31 @@
 		this.roadSpeed = other.roadSpeed;
 		this.type = other.type;
 	}
+	
+	/**
+	 * Copy all attributes and replace type to a non-routable one.
+	 * @param other
+	 * @param nonRoutableType
+	 */
+	public GType(GType other, String nonRoutableType) {
+		assert other.featureKind == FeatureKind.POLYLINE;
+		
+		this.continueSearch = other.continueSearch;
+		this.defaultName = other.defaultName;
+		this.featureKind = other.featureKind;
+		this.maxLevel = other.maxLevel;
+		this.maxResolution = other.maxResolution;
+		this.minLevel = other.minLevel;
+		this.minResolution = other.minResolution;
+		this.propogateActionsOnContinue = other.propogateActionsOnContinue;
+		this.road = false;
+		try {
+			this.type = Integer.decode(nonRoutableType);
+		} catch (NumberFormatException e) {
+			log.error("not numeric " + nonRoutableType);
+			throw new ExitException("non-numeric type in style file");
+		}
+	}
 
 	public FeatureKind getFeatureKind() {
 		return featureKind;
