Index: uk/me/parabola/mkgmap/osmstyle/RoadMerger.java
===================================================================
--- uk/me/parabola/mkgmap/osmstyle/RoadMerger.java	(revision 2914)
+++ uk/me/parabola/mkgmap/osmstyle/RoadMerger.java	(working copy)
@@ -160,13 +160,6 @@
 				return false;
 			}
 			
-			// check road speed and road class
-			if (getRoadClass() != otherRoad.getRoadClass())
-				return false;
-			if (getRoadSpeedClass() != otherRoad.getRoadSpeedClass())
-				return false;
-			
-
 			// checks if the tag values of both ways match so that the ways
 			// can be merged
 			if (isWayMergable(mergePoint, otherRoad.getWay()) == false) {
@@ -177,36 +170,6 @@
 		}
 
 		/**
-		 * Retrieves the real road speed of this road that will be used by the
-		 * {@link MapRoad}. This is a combination of the gtypes road speed and
-		 * the tag {@code mkgmap:road-speed-class}. 
-		 * 
-		 * @return road speed class
-		 */
-		protected int getRoadSpeedClass() {
-			int roadSpeed = gtype.getRoadSpeed();
-			String roadSpeedClassTag = way.getTag("mkgmap:road-speed-class");
-			if (roadSpeedClassTag != null)
-				roadSpeed = Integer.valueOf(roadSpeedClassTag);
-			return roadSpeed;
-		}
-
-		/**
-		 * Retrieves the real road class of this road that will be used by the
-		 * {@link MapRoad}. This is a combination of the gtypes road class and
-		 * the tag {@code mkgmap:road-class}. 
-		 * 
-		 * @return road class
-		 */
-		protected int getRoadClass() {
-			int roadClass = gtype.getRoadClass();
-			String roadClassTag = way.getTag("mkgmap:road-class");
-			if (roadClassTag != null) 
-				roadClass = Integer.valueOf(roadClassTag);
-			return roadClass;
-		}
-		
-		/**
 		 * Checks if the given GType can be merged with the GType of this road.
 		 * @param otherGType the GType of the other road
 		 * @return {@code true} both GType objects can be merged; {@code false} GType 
@@ -233,7 +196,12 @@
 			if (gtype.getMaxLevel() != otherGType.getMaxLevel()) {
 				return false;
 			}
-			
+			if (gtype.getRoadClass() != otherGType.getRoadClass()){
+				return false;
+			}
+			if (gtype.getRoadSpeed() != otherGType.getRoadSpeed()){
+				return false;
+			}
 // default name is applied before the RoadMerger starts
 // so they needn't be equal 
 //			if (stringEquals(gtype.getDefaultName(),
Index: uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
===================================================================
--- uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(revision 2914)
+++ uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(working copy)
@@ -311,6 +311,76 @@
 	}
 
 	/**
+	 * Evaluate the tag key mkgmap:road-class.
+	 * @param el an element 
+	 * @param type a GType instance with the current road class.
+	 * @return the new road class.
+	 */
+	private int evalRoadClassTag(Element el, GType type) {
+		int roadClass = type.getRoadClass();
+		String val = el.getTag("mkgmap:road-class");
+		if (val != null) {
+			if (val.startsWith("-")) {
+				roadClass -= Integer.decode(val.substring(1));
+			} else if (val.startsWith("+")) {
+				roadClass += Integer.decode(val.substring(1));
+			} else {
+				roadClass = Integer.decode(val);
+			}
+			val = el.getTag("mkgmap:road-class-max");
+			int roadClassMax = 4;
+			if (val != null)
+				roadClassMax = Integer.decode(val);
+			val = el.getTag("mkgmap:road-class-min");
+
+			int roadClassMin = 0;
+			if (val != null)
+				roadClassMin = Integer.decode(val);
+			if (roadClass > roadClassMax)
+				roadClass = roadClassMax;
+			else if (roadClass < roadClassMin)
+				roadClass = roadClassMin;
+		}
+		return roadClass;
+	}
+	
+	/**
+	 * Evaluate the tag key mkgmap:road-speed.
+	 * @param el an element 
+	 * @param type a GType instance with the current road speed.
+	 * @return the new road speed.
+	 */
+	private int evalRoadSpeedTag(Element el, GType type) {
+		int roadSpeed = type.getRoadSpeed();
+		String val = el.getTag("mkgmap:road-speed");
+		if(val != null) {
+			if(val.startsWith("-")) {
+				roadSpeed -= Integer.decode(val.substring(1));
+			}
+			else if(val.startsWith("+")) {
+				roadSpeed += Integer.decode(val.substring(1));
+			}
+			else {
+				roadSpeed = Integer.decode(val);
+			}
+			val = el.getTag("mkgmap:road-speed-max");
+			int roadSpeedMax = 7;
+			if(val != null)
+				roadSpeedMax = Integer.decode(val);
+			val = el.getTag("mkgmap:road-speed-min");
+
+			int roadSpeedMin = 0;
+			if(val != null)
+				roadSpeedMin = Integer.decode(val);
+			if(roadSpeed > roadSpeedMax)
+				roadSpeed = roadSpeedMax;
+			else if(roadSpeed < roadSpeedMin)
+				roadSpeed = roadSpeedMin;
+		}
+		return roadSpeed;
+	}
+	
+	/**
 	 * Built in rules to run after converting the element.
 	 */
 	private void postConvertRules(Element el, GType type) {
@@ -320,41 +390,11 @@
 		
 		if (el instanceof Way && type.isRoad()) {
 			Way way = (Way) el;
-
-			// road class (can be overridden by mkgmap:road-class tag)
-			int roadClass = type.getRoadClass();
-			String val = way.getTag("mkgmap:road-class");
-			if (val != null) {
-				if (val.startsWith("-")) {
-					roadClass -= Integer.decode(val.substring(1));
-				} else if (val.startsWith("+")) {
-					roadClass += Integer.decode(val.substring(1));
-				} else {
-					roadClass = Integer.decode(val);
-				}
-				val = way.getTag("mkgmap:road-class-max");
-				int roadClassMax = 4;
-				if (val != null)
-					roadClassMax = Integer.decode(val);
-				val = way.getTag("mkgmap:road-class-min");
-
-				int roadClassMin = 0;
-				if (val != null)
-					roadClassMin = Integer.decode(val);
-				if (roadClass > roadClassMax)
-					roadClass = roadClassMax;
-				else if (roadClass < roadClassMin)
-					roadClass = roadClassMin;
-				
-				if (log.isInfoEnabled())
-					log.info("POI changing road class of" + way.getName() + " ("
-						+ way.getId() + ") to " + roadClass + " at "
-						+ way.getPoints().get(0));
-			}
-			if (roadClass == type.getRoadClass()) {
+			
+			int roadClass = evalRoadClassTag(way, type);
+			if (roadClass != type.getRoadClass()){
+				type.setRoadClass(roadClass);
 				way.deleteTag("mkgmap:road-class");
-			} else {
-				way.addTag("mkgmap:road-class", String.valueOf(roadClass));
 			}
 			
 			int roadSpeed = type.getRoadSpeed();
@@ -375,42 +415,15 @@
 							+ " road classification mkgmap:road-speed-class="
 							+ roadSpeedOverride + " must be in [0;7]");
 				}
+				type.setRoadSpeed(roadSpeed);
+				way.deleteTag("mkgmap:road-speed-class");
 			}
 
-			val = way.getTag("mkgmap:road-speed");
-			if(val != null) {
-				if(val.startsWith("-")) {
-					roadSpeed -= Integer.decode(val.substring(1));
-				}
-				else if(val.startsWith("+")) {
-					roadSpeed += Integer.decode(val.substring(1));
-				}
-				else {
-					roadSpeed = Integer.decode(val);
-				}
-				val = way.getTag("mkgmap:road-speed-max");
-				int roadSpeedMax = 7;
-				if(val != null)
-					roadSpeedMax = Integer.decode(val);
-				val = way.getTag("mkgmap:road-speed-min");
-
-				int roadSpeedMin = 0;
-				if(val != null)
-					roadSpeedMin = Integer.decode(val);
-				if(roadSpeed > roadSpeedMax)
-					roadSpeed = roadSpeedMax;
-				else if(roadSpeed < roadSpeedMin)
-					roadSpeed = roadSpeedMin;
-				if (log.isInfoEnabled())
-					log.info("POI changing road speed of " + way.getName()
-							+ " (" + way.getId() + ") to " + roadSpeed + " at "
-							+ way.getPoints().get(0));
+			roadSpeed = evalRoadSpeedTag(way, type);
+			if (roadSpeed != type.getRoadSpeed()){
+				type.setRoadSpeed(roadSpeed);
+				way.deleteTag("mkgmap:road-speed");
 			}
-			if (roadSpeed == type.getRoadSpeed()) {
-				way.deleteTag("mkgmap:road-speed-class");
-			} else {
-				way.addTag("mkgmap:road-speed-class", String.valueOf(roadSpeed));
-			}
 		}
 	}
 
@@ -765,7 +778,8 @@
 	 * @param way the way
 	 * @param gt the type assigned by the style
 	 */
-	private void addRoad(Way way, GType gt) {
+	private void addRoad(Way way, GType gtParm) {
+		GType gt = new GType(gtParm);
 		if (way.getPoints().size() < 2){
 			log.warn("road has < 2 points ",way.getId(),"(discarding)");
 			return;
@@ -876,26 +890,15 @@
 								// recursively process tail of way
 								addRoad(tail, gt);
 							}
-							// we can't modify the road class or type in
-							// the GType as that's global so for now just
-							// transfer the tags to the way
-							if(roadClass != null) {
-								way.addTag("mkgmap:road-class", roadClass);
-								String val = node.getTag("mkgmap:road-class-min");
-								if(val != null)
-									way.addTag("mkgmap:road-class-min", val);
-								val = node.getTag("mkgmap:road-class-max");
-								if(val != null)
-									way.addTag("mkgmap:road-class-max", val);
+							int roadClassInt = evalRoadClassTag(node, gt);
+							if (roadClassInt != gt.getRoadClass()){
+								gt.setRoadClass(roadClassInt);
+								log.info("POI changing road class of " + way.toBrowseURL() + " to " + roadClassInt + " at " + points.get(0).toOSMURL()); 								
 							}
-							if(roadSpeed != null) {
-								way.addTag("mkgmap:road-speed", roadSpeed);
-								String val = node.getTag("mkgmap:road-speed-min");
-								if(val != null)
-									way.addTag("mkgmap:road-speed-min", val);
-								val = node.getTag("mkgmap:road-speed-max");
-								if(val != null)
-									way.addTag("mkgmap:road-speed-max", val);
+							int roadSpeedInt = evalRoadSpeedTag(node, gt);
+							if (roadSpeedInt != gt.getRoadSpeed()){
+								gt.setRoadSpeed(roadSpeedInt);
+								log.info("POI changing road speed of " + way.toBrowseURL() + " to " + roadSpeedInt + " at " + points.get(0).toOSMURL());
 							}
 						}
 					}
@@ -1076,7 +1079,8 @@
 		}
 	}
 
-	private void addRoadAfterSplittingLoops(Way way, GType gt) {
+	private void addRoadAfterSplittingLoops(Way way, final GType gtParm) {
+		GType gt = new GType(gtParm);
 		// make sure the way has nodes at each end
 		way.getPoints().get(0).incHighwayCount();
 		way.getPoints().get(way.getPoints().size() - 1).incHighwayCount();
@@ -1346,7 +1350,7 @@
 		MapLine line = new MapLine();
 		elementSetup(line, gt, way);
 		line.setPoints(points);
-
+		
 		MapRoad road = new MapRoad(way.getId(), line);
 		if (way.isBoolTag("mkgmap:skipSizeFilter"))
 			road.setSkipSizeFilter(true);
@@ -1375,18 +1379,9 @@
 		// set road parameters 
 
 		// copy road class and road speed
-		int roadClass = gt.getRoadClass();
-		String roadClassTag = way.getTag("mkgmap:road-class");
-		if (roadClassTag != null) 
-			roadClass = Integer.valueOf(roadClassTag);
-		road.setRoadClass(roadClass);
+		road.setRoadClass(gt.getRoadClass());
+		road.setSpeed(gt.getRoadSpeed());
 		
-		int roadSpeed = gt.getRoadSpeed();
-		String roadSpeedClassTag = way.getTag("mkgmap:road-speed-class");
-		if (roadSpeedClassTag != null)
-			roadSpeed = Integer.valueOf(roadSpeedClassTag);
-		road.setSpeed(roadSpeed);
-		
 		if (way.isBoolTag("oneway")) {
 			road.setDirection(true);
 			road.setOneway();
@@ -1497,6 +1492,7 @@
 			String access = String.format("%11s",Integer.toBinaryString(cmpAccess)).replace(' ', '0');
 			roadLog.info(String.format("%19d 0x%-2x %11s %s", way.getId(), road.getType(), access, Arrays.toString(road.getLabels())));
 		}
+		
 		// add the road to the housenumber generator
 		// it will add the road later on to the lineAdder
 		housenumberGenerator.addRoad(way, road);
