Index: applications/editors/josm/plugins/smed2/jharbour/build.xml
===================================================================
--- applications/editors/josm/plugins/smed2/jharbour/build.xml	(revision 30233)
+++ applications/editors/josm/plugins/smed2/jharbour/build.xml	(revision 30269)
@@ -9,5 +9,5 @@
 
   <target name="compile" depends="init" description="compile the source " >
-    <javac srcdir="${src}" destdir="${build}"/>
+    <javac includeantruntime="false" srcdir="${src}" destdir="${build}"/>
   </target>
 
Index: applications/editors/josm/plugins/smed2/jrender/build.xml
===================================================================
--- applications/editors/josm/plugins/smed2/jrender/build.xml	(revision 30233)
+++ applications/editors/josm/plugins/smed2/jrender/build.xml	(revision 30269)
@@ -9,5 +9,5 @@
 
   <target name="compile" depends="init" description="compile the source " >
-    <javac srcdir="${src}" destdir="${build}"/>
+    <javac includeantruntime="false" srcdir="${src}" destdir="${build}"/>
   </target>
 
Index: applications/editors/josm/plugins/smed2/js57toosm/build.xml
===================================================================
--- applications/editors/josm/plugins/smed2/js57toosm/build.xml	(revision 30233)
+++ applications/editors/josm/plugins/smed2/js57toosm/build.xml	(revision 30269)
@@ -9,5 +9,5 @@
 
   <target name="compile" depends="init" description="compile the source " >
-    <javac srcdir="${src}" destdir="${build}"/>
+    <javac includeantruntime="false" srcdir="${src}" destdir="${build}"/>
   </target>
 
Index: applications/editors/josm/plugins/smed2/js57toosm/src/js57toosm/Js57toosm.java
===================================================================
--- applications/editors/josm/plugins/smed2/js57toosm/src/js57toosm/Js57toosm.java	(revision 30233)
+++ applications/editors/josm/plugins/smed2/js57toosm/src/js57toosm/Js57toosm.java	(revision 30269)
@@ -115,7 +115,11 @@
 						break;
 					case "FFPT":
-						name = (long) S57dat.getSubf(record, fields + pos, S57field.FFPT, S57subf.LNAM);
-						int rind = ((Long) S57dat.getSubf(S57subf.RIND)).intValue();
-						map.newObj(name, rind);
+						S57dat.setField(record, fields + pos, S57field.FFPT, len);
+						do {
+							name = (long) S57dat.getSubf(S57subf.LNAM);
+							int rind = ((Long) S57dat.getSubf(S57subf.RIND)).intValue();
+							S57dat.getSubf(S57subf.COMT);
+							map.newObj(name, rind);
+						} while (S57dat.more());
 						break;
 					case "FSPT":
@@ -124,4 +128,5 @@
 							name = (Long) S57dat.getSubf(S57subf.NAME) << 16;
 							map.newPrim(name, (long) S57dat.getSubf(S57subf.ORNT), (long) S57dat.getSubf(S57subf.USAG));
+							S57dat.getSubf(S57subf.MASK);
 						} while (S57dat.more());
 						break;
@@ -153,4 +158,5 @@
 							int topi = ((Long) S57dat.getSubf(S57subf.TOPI)).intValue();
 							map.addConn(name, topi);
+							S57dat.getSubf(S57subf.MASK);
 						} while (S57dat.more());
 						break;
@@ -209,17 +215,21 @@
 		for (long id : map.index.keySet()) {
 			Feature feature = map.index.get(id);
-			if (feature.reln != Rflag.SLAVE) {
-				if (feature.geom.prim == Pflag.POINT) {
-					for (Prim prim : feature.geom.elems) {
-						long ref = prim.id;
-						Snode node = map.nodes.get(ref);
-						out.format("  <node id='%d' lat='%f' lon='%f' version='1'>%n", -ref, Math.toDegrees(node.lat), Math.toDegrees(node.lon));
-						String type = S57obj.stringType(feature.type);
-						out.format("    <tag k='seamark:type' v=\"%s\"/>%n", type);
-						if ((feature.type == Obj.SOUNDG) && (node.flg == S57map.Nflag.DPTH))
-							out.format("    <tag k='seamark:sounding:depth' v='%.1f'/>%n", ((Dnode)node).val);
-						writeAtts(feature, type);
-						out.format("  </node>%n");
-						map.nodes.remove(ref);
+			String type = S57obj.stringType(feature.type);
+			if (!type.isEmpty()) {
+				if (feature.reln == Rflag.MASTER) {
+					if (feature.geom.prim == Pflag.POINT) {
+						for (Prim prim : feature.geom.elems) {
+							long ref = prim.id;
+							Snode node;
+							while ((node = map.nodes.get(ref)) != null) {
+								out.format("  <node id='%d' lat='%.8f' lon='%.8f' version='1'>%n", -ref, Math.toDegrees(node.lat), Math.toDegrees(node.lon));
+								out.format("    <tag k='seamark:type' v=\"%s\"/>%n", type);
+								if ((feature.type == Obj.SOUNDG) && (node.flg == S57map.Nflag.DPTH))
+									out.format("    <tag k='seamark:sounding:depth' v='%.1f'/>%n", ((Dnode) node).val);
+								writeAtts(feature, type);
+								out.format("  </node>%n");
+								map.nodes.remove(ref++);
+							}
+						}
 					}
 				}
@@ -227,35 +237,39 @@
 		}
 		
+//int i = 256;
 		for (long id : map.index.keySet()) {
+//if (i-- == 0) break;
 			Feature feature = map.index.get(id);
-			if (feature.reln != Rflag.SLAVE) {
-				if ((feature.geom.prim == Pflag.LINE) || ((feature.geom.prim == Pflag.AREA) && (feature.geom.outers == 1) && (feature.geom.inners == 0))) {
-					GeomIterator git = map.new GeomIterator(feature.geom);
-					while (git.hasMore()) {
-						git.getMore();
-						while (git.hasNext()) {
-							long ref = git.nextRef();
-							Snode node = map.nodes.get(ref);
-							if (node != null) {
-								out.format("  <node id='%d' lat='%f' lon='%f' version='1'/>%n", -ref, Math.toDegrees(node.lat), Math.toDegrees(node.lon));
-								map.nodes.remove(ref);
+			String type = S57obj.stringType(feature.type);
+			if (!type.isEmpty()) {
+				if (feature.reln == Rflag.MASTER) {
+					if ((feature.geom.prim == Pflag.LINE) || ((feature.geom.prim == Pflag.AREA) && (feature.geom.outers == 1) && (feature.geom.inners == 0))) {
+						GeomIterator git = map.new GeomIterator(feature.geom);
+						while (git.hasMore()) {
+							git.getMore();
+							while (git.hasNext()) {
+								long ref = git.nextRef();
+								Snode node = map.nodes.get(ref);
+								if (node != null) {
+									out.format("  <node id='%d' lat='%.8f' lon='%.8f' version='1'/>%n", -ref, Math.toDegrees(node.lat), Math.toDegrees(node.lon));
+									map.nodes.remove(ref);
+								}
 							}
 						}
+						git = map.new GeomIterator(feature.geom);
+						while (git.hasMore()) {
+							long way = git.getMore();
+							out.format("  <way id='%d' version='1'>%n", -way);
+							while (git.hasNext()) {
+								long ref = git.nextRef();
+								out.format("    <nd ref='%d'/>%n", -ref);
+							}
+							out.format("    <tag k='seamark:type' v=\"%s\"/>%n", type);
+							writeAtts(feature, type);
+							out.format("  </way>%n");
+						}
+					} else if (feature.geom.prim == Pflag.AREA) {
+
 					}
-					git = map.new GeomIterator(feature.geom);
-					while (git.hasMore()) {
-						long way = git.getMore();
-						out.format("  <way id='%d' version='1'>%n", -way);
-						while (git.hasNext()) {
-							long ref = git.nextRef();
-							out.format("    <nd ref='%d'/>%n", -ref);
-						}
-						String type = S57obj.stringType(feature.type);
-						out.format("    <tag k='seamark:type' v=\"%s\"/>%n", type);
-						writeAtts(feature, type);
-						out.format("  </way>%n");
-					}
-				} else if (feature.geom.prim == Pflag.AREA) {
-					
 				}
 			}
@@ -271,17 +285,22 @@
 				out.format("    <tag k='seamark:%s:%s' v=\"%s\"/>%n", type, attstr, valstr);
 		}
-		for (Reln rel : feature.rels) {
-			if (rel.reln == Rflag.SLAVE) {
-				Feature slave = map.index.get(rel.id);
-				type = S57obj.stringType(slave.type);
-				for (Map.Entry<Att, AttVal<?>> item : slave.atts.entrySet()) {
+		for (Obj obj : feature.objs.keySet()) {
+			ObjTab tab = feature.objs.get(obj);
+			for (int ix : tab.keySet()) {
+				type = S57obj.stringType(obj);
+				AttMap atts = tab.get(ix);
+				for (Map.Entry<Att, AttVal<?>> item : atts.entrySet()) {
 					String attstr = S57att.stringAttribute(item.getKey());
 					String valstr = S57val.stringValue(item.getValue());
-					if (!attstr.isEmpty() && !valstr.isEmpty())
-						out.format("    <tag k='seamark:%s:%s' v=\"%s\"/>%n", type, attstr, valstr);
+					if (!attstr.isEmpty() && !valstr.isEmpty()) {
+						if ((ix == 0) && (tab.size() == 1)) {
+							out.format("    <tag k='seamark:%s:%s' v=\"%s\"/>%n", type, attstr, valstr);
+						} else {
+							out.format("    <tag k='seamark:%s:%d:%s' v=\"%s\"/>%n", type, ix + 1, attstr, valstr);
+						}
+					}
 				}
 			}
 		}
-
 	}
 
Index: applications/editors/josm/plugins/smed2/src/panels/PanelMain.java
===================================================================
--- applications/editors/josm/plugins/smed2/src/panels/PanelMain.java	(revision 30233)
+++ applications/editors/josm/plugins/smed2/src/panels/PanelMain.java	(revision 30269)
@@ -146,5 +146,5 @@
 		for (Obj obj : feature.objs.keySet()) {
 			decode.append("\t\t" + Messages.getString(obj.name()) + "\n");
-			if (feature.objs.get(obj).size() != 0) {
+/*			if (feature.aggr.objs.get(obj).size() != 0) {
 				for (AttMap atts : feature.objs.get(obj).values()) {
 					for (Att att : atts.keySet()) {
@@ -172,5 +172,5 @@
 				}
 			}
-		}
+*/		}
 	}
 	
Index: applications/editors/josm/plugins/smed2/src/render/Renderer.java
===================================================================
--- applications/editors/josm/plugins/smed2/src/render/Renderer.java	(revision 30233)
+++ applications/editors/josm/plugins/smed2/src/render/Renderer.java	(revision 30269)
@@ -81,17 +81,17 @@
 
 	public static void symbol(Feature feature, Symbol symbol) {
-		Point2D point = context.getPoint(feature.centre);
+		Point2D point = context.getPoint(feature.geom.centre);
 		Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), null, null);
 	}
 	public static void symbol(Feature feature, Symbol symbol, Scheme scheme) {
-		Point2D point = context.getPoint(feature.centre);
+		Point2D point = context.getPoint(feature.geom.centre);
 		Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), scheme, null);
 	}
 	public static void symbol(Feature feature, Symbol symbol, Delta delta) {
-		Point2D point = context.getPoint(feature.centre);
+		Point2D point = context.getPoint(feature.geom.centre);
 		Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), null, delta);
 	}
 	public static void symbol(Feature feature, Symbol symbol, Scheme scheme, Delta delta) {
-		Point2D point = context.getPoint(feature.centre);
+		Point2D point = context.getPoint(feature.geom.centre);
 		Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), scheme, delta);
 	}
@@ -334,5 +334,5 @@
 		circle.add(new Instr(Form.STRK, new BasicStroke(style.width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, style.dash, 0)));
 		circle.add(new Instr(Form.ELPS, new Ellipse2D.Double(-radius,-radius,radius*2,radius*2)));
-		Point2D point = context.getPoint(feature.centre);
+		Point2D point = context.getPoint(feature.geom.centre);
 		Symbols.drawSymbol(g2, circle, 1, point.getX(), point.getY(), null, null);
 	}
@@ -345,5 +345,5 @@
 		switch (feature.geom.prim) {
 		case POINT:
-			point = context.getPoint(feature.centre);
+			point = context.getPoint(feature.geom.centre);
 			g2.drawImage(image, new AffineTransformOp(AffineTransform.getScaleInstance(sScale, sScale), AffineTransformOp.TYPE_NEAREST_NEIGHBOR),
 					(int)(point.getX() - (50 * sScale)), (int)(point.getY() - (50 * sScale)));
@@ -478,5 +478,5 @@
 		}
 		label.add(new Instr(Form.TEXT, new Caption(str, font, tc, new Delta(Handle.TL, AffineTransform.getTranslateInstance(tx, ty)))));
-		Point2D point = context.getPoint(feature.centre);
+		Point2D point = context.getPoint(feature.geom.centre);
 		Symbols.drawSymbol(g2, label, sScale, point.getX(), point.getY(), null, delta);
 	}
Index: applications/editors/josm/plugins/smed2/src/render/Rules.java
===================================================================
--- applications/editors/josm/plugins/smed2/src/render/Rules.java	(revision 30233)
+++ applications/editors/josm/plugins/smed2/src/render/Rules.java	(revision 30269)
@@ -193,5 +193,5 @@
 			break;
 		case FAIRWY:
-			if (feature.area > 2.0) {
+			if (feature.geom.area > 2.0) {
 				if (Renderer.zoom < 16)
 					Renderer.lineVector(feature, new LineStyle(Mline, 8, new float[] { 50, 50 }, new Color(0x40ffffff, true)));
@@ -208,5 +208,5 @@
 					Renderer.symbol(feature, Areas.MarineFarm);
 				}
-				if ((feature.area > 0.2) || ((feature.area > 0.05) && (Renderer.zoom >= 14)) || ((feature.area > 0.005) && (Renderer.zoom >= 16))) {
+				if ((feature.geom.area > 0.2) || ((feature.geom.area > 0.05) && (Renderer.zoom >= 14)) || ((feature.geom.area > 0.005) && (Renderer.zoom >= 16))) {
 					Renderer.lineVector(feature, new LineStyle(Color.black, 4, new float[] { 10, 10 }));
 				}
@@ -385,5 +385,5 @@
 	
 	private static void cables(Feature feature) {
-		if ((Renderer.zoom >= 16) && (feature.length < 2)) {
+		if ((Renderer.zoom >= 16) && (feature.geom.length < 2)) {
 			if (feature.type == Obj.CBLSUB) {
 				Renderer.lineSymbols(feature, Areas.Cable, 0.0, null, null, 0, Mline);
@@ -898,10 +898,10 @@
 
 	private static void pipelines(Feature feature) {
-		if ((Renderer.zoom >= 16) && (feature.length < 2)) {
+		if ((Renderer.zoom >= 16) && (feature.geom.length < 2)) {
 			if (feature.type == Obj.PIPSOL) {
 				Renderer.lineSymbols(feature, Areas.Pipeline, 1.0, null, null, 0, Mline);
 			} else if (feature.type == Obj.PIPOHD) {
 				Renderer.lineVector(feature, new LineStyle(Color.black, 8));
-				AttMap atts = feature.objs.get(Obj.PIPOHD).get(0);
+				AttMap atts = feature.atts;
 				double verclr = 0;
 				if (atts != null) {
Index: applications/editors/josm/plugins/smed2/src/s57/S57att.java
===================================================================
--- applications/editors/josm/plugins/smed2/src/s57/S57att.java	(revision 30233)
+++ applications/editors/josm/plugins/smed2/src/s57/S57att.java	(revision 30269)
@@ -146,5 +146,5 @@
 		AttStr.put(Att.BUNVES, "availability");	AttStr.put(Att.CATBRT, "category"); AttStr.put(Att.CATBUN, "category"); AttStr.put(Att.CATCCL, "category");
 		AttStr.put(Att.CATHBR, "category");	AttStr.put(Att.CATRFD, "category"); AttStr.put(Att.CATTML, "category"); AttStr.put(Att.COMCTN, "communication");
-		AttStr.put(Att.HORCLL, "horizontal_clearance_length");	AttStr.put(Att.HORCLW, "horizontal_clearance_width"); AttStr.put(Att.TRSHGD, "goods"); AttStr.put(Att.UNLOCD, "locode");
+		AttStr.put(Att.HORCLL, "horizontal_clearance_length");	AttStr.put(Att.HORCLW, "horizontal_clearance_width"); AttStr.put(Att.TRSHGD, "goods"); AttStr.put(Att.UNLOCD, "");
 		AttStr.put(Att.CATGAG, "category");	AttStr.put(Att.HIGWAT, "high_value"); AttStr.put(Att.HIGNAM, "high_name"); AttStr.put(Att.LOWWAT, "low_value");
 		AttStr.put(Att.LOWNAM, "low_name");	AttStr.put(Att.MEAWAT, "mean_value"); AttStr.put(Att.MEANAM, "mean_name"); AttStr.put(Att.OTHWAT, "local_value");
Index: applications/editors/josm/plugins/smed2/src/s57/S57dat.java
===================================================================
--- applications/editors/josm/plugins/smed2/src/s57/S57dat.java	(revision 30233)
+++ applications/editors/josm/plugins/smed2/src/s57/S57dat.java	(revision 30269)
@@ -173,5 +173,5 @@
 	
 	public static boolean more() {
-		return ((offset < maxoff) && (buffer[offset+1] != 0x1e));
+		return ((offset < maxoff) && (buffer[offset] != 0x1e));
 	}
 	
Index: applications/editors/josm/plugins/smed2/src/s57/S57map.java
===================================================================
--- applications/editors/josm/plugins/smed2/src/s57/S57map.java	(revision 30233)
+++ applications/editors/josm/plugins/smed2/src/s57/S57map.java	(revision 30269)
@@ -80,5 +80,5 @@
 	
 	public enum Rflag {
-		UNKN, AGGR, MASTER, SLAVE, PEER
+		UNKN, AGGR, MASTER, SLAVE
 	}
 	
@@ -92,25 +92,34 @@
 	}
 
+	public class RelTab extends ArrayList<Reln> {
+		public RelTab() {
+			super();
+		}
+	}
+
+	public class ObjTab extends HashMap<Integer, AttMap> {
+		public ObjTab() {
+			super();
+		}
+	}
+
+	public class ObjMap extends EnumMap<Obj, ObjTab> {
+		public ObjMap() {
+			super(Obj.class);
+		}
+	}
+
+	public class Aggr {
+		public RelTab rels;
+		public long par;
+		public Aggr() {
+			rels = new RelTab();
+			par = 0;
+		}
+	}
+
 	public class AttMap extends HashMap<Att, AttVal<?>> {
 		public AttMap() {
 			super();
-		}
-	}
-
-	public class RelTab extends ArrayList<Reln> {
-		public RelTab() {
-			super();
-		}
-	}
-
-	public class ObjTab extends HashMap<Integer, AttMap> {
-		public ObjTab() {
-			super();
-		}
-	}
-
-	public class ObjMap extends EnumMap<Obj, ObjTab> {
-		public ObjMap() {
-			super(Obj.class);
 		}
 	}
@@ -177,4 +186,7 @@
 		public int inners;						// Number of inners
 		public ArrayList<Comp> refs;	// Ordered list of compounds
+		public double area;						// Area of feature
+		public double length;					// Length of feature
+		public Snode centre;					// Centre of feature
 		public Geom(Pflag p) {
 			prim = p;
@@ -182,4 +194,7 @@
 			outers = inners = 0;
 			refs = new ArrayList<Comp>();
+			area = 0;
+			length = 0;
+			centre = new Snode();
 		}
 	}
@@ -190,9 +205,6 @@
 		public Obj type;			// Feature type
 		public AttMap atts;		// Feature attributes
-		public RelTab rels;		// Related objects
-		public ObjMap objs;		// Slave objects
-		public double area;		// Area of feature
-		public double length;	// Length of feature
-		public Snode centre;	// Centre of feature
+		public Aggr aggr;			// Related objects
+		public ObjMap objs;		// Slave object attributes
 
 		Feature() {
@@ -201,9 +213,6 @@
 			type = Obj.C_AGGR;
 			atts = new AttMap();
-			rels = new RelTab();
+			aggr = new Aggr();
 			objs = new ObjMap();
-			area = 0;
-			length = 0;
-			centre = new Snode();
 		}
 	}
@@ -249,5 +258,7 @@
 		feature.geom = new Geom(p);
 		feature.type = obj;
-		index.put(id, feature);
+		if (obj != Obj.UNKOBJ) {
+			index.put(id, feature);
+		}
 	}
 	
@@ -262,8 +273,8 @@
 			break;
 		case 3:
-			r = Rflag.PEER;
+			r = Rflag.UNKN;
 			break;
 		}
-		feature.rels.add(new Reln(id, r));
+		feature.aggr.rels.add(new Reln(id, r));
 	}
 	
@@ -296,11 +307,11 @@
 
 	public void endFile() {
+		sortGeom();
 		for (long id : index.keySet()) {
 			Feature feature = index.get(id);
-			for (Reln rel : feature.rels) {
-				Feature reln = index.get(rel.id);
-				reln.reln = rel.reln;
-				if (feature.reln == Rflag.UNKN) {
-					switch (rel.reln) {
+			for (Reln reln : feature.aggr.rels) {
+				Feature rel = index.get(reln.id);
+				if (cmpGeoms(feature.geom, rel.geom)) {
+					switch (reln.reln) {
 					case MASTER:
 						feature.reln = Rflag.AGGR;
@@ -308,17 +319,13 @@
 					case SLAVE:
 						feature.reln = Rflag.MASTER;
-					case PEER:
-						feature.reln = Rflag.PEER;
 						break;
 					default:
+						feature.reln = Rflag.UNKN;
 						break;
 					}
-				}
-				ObjTab tab = feature.objs.get(reln.type);
-				if (tab == null) {
-					tab = new ObjTab();
-					feature.objs.put(reln.type, tab);
-				}
-				tab.put(tab.size(), reln.atts);
+					rel.reln = reln.reln; 
+				} else {
+					reln.reln = Rflag.UNKN;
+				}
 			}
 		}
@@ -328,5 +335,5 @@
 				feature.reln = Rflag.MASTER;
 			}
-			if ((feature.type != Obj.UNKOBJ) && ((feature.reln == Rflag.MASTER) || (feature.reln == Rflag.PEER))) {
+			if ((feature.type != Obj.UNKOBJ) && (feature.reln == Rflag.MASTER)) {
 				if (features.get(feature.type) == null) {
 					features.put(feature.type, new ArrayList<Feature>());
@@ -335,5 +342,18 @@
 			}
 		}
-		sortGeom();
+		for (long id : index.keySet()) {
+			Feature feature = index.get(id);
+			for (Reln reln : feature.aggr.rels) {
+				Feature rel = index.get(reln.id);
+				if (rel.reln == Rflag.SLAVE) {
+					if (feature.objs.get(rel.type) == null) {
+						feature.objs.put(rel.type, new ObjTab());
+					}
+					ObjTab tab = feature.objs.get(rel.type);
+					int ix = tab.size();
+					tab.put(ix, rel.atts);
+				}
+			}
+		}
 	}
 
@@ -401,18 +421,26 @@
 					items = new ObjTab();
 					feature.objs.put(obj, items);
-				}
-				AttMap atts = items.get(idx);
-				if (atts == null) {
-					atts = new AttMap();
-					items.put(idx, atts);
-				}
-				AttVal<?> attval = S57val.convertValue(val, att);
-				if (attval.val != null)
-					atts.put(att, attval);
+					Feature type = new Feature();
+					type.reln = Rflag.SLAVE;
+					type.type = obj;
+					type.geom = feature.geom;
+				}
+//				AttMap atts = items.get(idx);
+//				if (atts == null) {
+//					atts = new AttMap();
+//					items.put(idx, atts);
+//				}
+//				AttVal<?> attval = S57val.convertValue(val, att);
+//				if (attval.val != null)
+//					atts.put(att, attval);
 			} else {
 				if (subkeys[1].equals("type")) {
-					feature.type = S57obj.enumType(val);
+					obj = S57obj.enumType(val);
 					if (feature.objs.get(feature.type) == null) {
 						feature.objs.put(feature.type, new ObjTab());
+						Feature type = new Feature();
+						type.reln = Rflag.MASTER;
+						type.type = obj;
+						type.geom = feature.geom;
 					}
 				} else {
@@ -435,6 +463,6 @@
 				node.flg = Nflag.ISOL;
 			}
-			feature.length = 0;
-			feature.area = 0;
+			feature.geom.length = 0;
+			feature.geom.area = 0;
 			break;
 		case LINE:
@@ -442,10 +470,10 @@
 			nodes.get(edge.first).flg = Nflag.CONN;
 			nodes.get(edge.last).flg = Nflag.CONN;
-			feature.length = calcLength(feature.geom);
+			feature.geom.length = calcLength(feature.geom);
 			if (edge.first == edge.last) {
 				feature.geom.prim = Pflag.AREA;
-				feature.area = calcArea(feature.geom);
+				feature.geom.area = calcArea(feature.geom);
 			} else {
-				feature.area = 0;
+				feature.geom.area = 0;
 			}
 			break;
@@ -460,6 +488,6 @@
 				features.put(feature.type, new ArrayList<Feature>());
 			}
-			feature.centre = findCentroid(feature);
 			features.get(feature.type).add(feature);
+			feature.geom.centre = findCentroid(feature);
 		}
 	}
@@ -470,14 +498,13 @@
 		for (long id : index.keySet()) {
 			feature = index.get(id);
-			Geom geom = feature.geom;
-			Geom sort = new Geom(geom.prim);
+			Geom sort = new Geom(feature.geom.prim);
 			long first = 0;
 			long last = 0;
 			Comp comp = null;
 			boolean next = true;
-			if ((geom.prim == Pflag.LINE) || (geom.prim == Pflag.AREA)) {
-				int sweep = geom.elems.size();
-				while (!geom.elems.isEmpty()) {
-					Prim prim = geom.elems.remove(0);
+			if ((feature.geom.prim == Pflag.LINE) || (feature.geom.prim == Pflag.AREA)) {
+				int sweep = feature.geom.elems.size();
+				while (!feature.geom.elems.isEmpty()) {
+					Prim prim = feature.geom.elems.remove(0);
 					Edge edge = edges.get(prim.id);
 					if (next == true) {
@@ -509,5 +536,5 @@
 								comp.size++;
 							} else {
-								geom.elems.add(prim);
+								feature.geom.elems.add(prim);
 							}
 						} else {
@@ -521,5 +548,5 @@
 								comp.size++;
 							} else {
-								geom.elems.add(prim);
+								feature.geom.elems.add(prim);
 							}
 						}
@@ -527,10 +554,13 @@
 					if (--sweep == 0) {
 						next = true;
-						sweep = geom.elems.size();
-					}
+						sweep = feature.geom.elems.size();
+					}
+				}
+				if ((sort.prim == Pflag.LINE) && (sort.outers == 1) && (sort.inners == 0) && (first == last)) {
+					sort.prim = Pflag.AREA;
 				}
 				feature.geom = sort;
 			} 
-			if (geom.prim == Pflag.AREA) {
+			if (feature.geom.prim == Pflag.AREA) {
 				ArrayList<Prim> outers = new ArrayList<Prim>();
 				ArrayList<Prim> inners = new ArrayList<Prim>();
@@ -544,5 +574,5 @@
 				ArrayList<Prim> sorting = outers;
 				ArrayList<Prim> closed = null;
-				sort = new Geom(geom.prim);
+				sort = new Geom(feature.geom.prim);
 				sort.outers = feature.geom.outers;
 				sort.inners = feature.geom.inners;
@@ -596,4 +626,8 @@
 	}
 	
+	public boolean cmpGeoms (Geom g1, Geom g2) {
+		return ((g1.prim == g2.prim) && (g1.outers == g2.outers) && (g1.inners == g2.inners) && (g1.elems.size() == g2.elems.size()));
+	}
+	
 	public class EdgeIterator {
 		Edge edge;
@@ -653,4 +687,5 @@
 		int cc, ec;
 		Comp comp;
+		long lastref;
 		
 		public GeomIterator(Geom g) {
@@ -659,4 +694,5 @@
 			cc = ec = 0;
 			comp = null;
+			lastref = 0;
 			if ((geom.prim != Pflag.NOSP) && (geom.prim != Pflag.POINT)) {
 				it = geom.elems.listIterator();
@@ -690,4 +726,8 @@
 			}
 			long ref = eit.nextRef();
+			if (ref == lastref) {
+				ref = eit.nextRef();
+			}
+			lastref = ref;
 			if (!eit.hasNext()) {
 				eit = null;
Index: applications/editors/josm/plugins/smed2/src/s57/S57obj.java
===================================================================
--- applications/editors/josm/plugins/smed2/src/s57/S57obj.java	(revision 30233)
+++ applications/editors/josm/plugins/smed2/src/s57/S57obj.java	(revision 30269)
@@ -8,5 +8,5 @@
 	
 	public enum Obj {
-		UNKOBJ, ADMARE, AIRARE, ACHBRT, ACHARE, BCNCAR, BCNISD, BCNLAT, BCNSAW, BCNSPP, BERTHS, BRIDGE, BUISGL, BUAARE, BOYCAR, BOYINB,
+		UNKOBJ, AIRARE, ACHBRT, ACHARE, BCNCAR, BCNISD, BCNLAT, BCNSAW, BCNSPP, BERTHS, BRIDGE, BUISGL, BUAARE, BOYCAR, BOYINB,
 		BOYISD, BOYLAT, BOYSAW, BOYSPP, CBLARE, CBLOHD, CBLSUB, CANALS, CANBNK, CTSARE, CAUSWY, CTNARE, CHKPNT, CGUSTA, COALNE, CONZNE,
 		COSARE, CTRPNT, CONVYR, CRANES, CURENT, CUSZNE, DAMCON, DAYMAR, DWRTCL, DWRTPT, DEPARE, DEPCNT, DISMAR, DOCARE, DRGARE, DRYDOC,
@@ -25,5 +25,5 @@
 	static {
 		ObjS57.put(Obj.UNKOBJ,0);
-		ObjS57.put(Obj.ADMARE,1); ObjS57.put(Obj.AIRARE,2); ObjS57.put(Obj.ACHBRT,3); ObjS57.put(Obj.ACHARE,4); ObjS57.put(Obj.BCNCAR,5);
+		ObjS57.put(Obj.AIRARE,2); ObjS57.put(Obj.ACHBRT,3); ObjS57.put(Obj.ACHARE,4); ObjS57.put(Obj.BCNCAR,5);
 		ObjS57.put(Obj.BCNISD,6); ObjS57.put(Obj.BCNLAT,7); ObjS57.put(Obj.BCNSAW,8); ObjS57.put(Obj.BCNSPP,9); ObjS57.put(Obj.BERTHS,10);
 		ObjS57.put(Obj.BRIDGE,11); ObjS57.put(Obj.BUISGL,12); ObjS57.put(Obj.BUAARE,13); ObjS57.put(Obj.BOYCAR,14); ObjS57.put(Obj.BOYINB,15);
@@ -88,5 +88,5 @@
 	private static final EnumMap<Obj, String> ObjStr = new EnumMap<Obj, String>(Obj.class);
 	static {
-		ObjStr.put(Obj.UNKOBJ, "");	ObjStr.put(Obj.ADMARE, "administrative_area");	ObjStr.put(Obj.AIRARE, "airfield");	ObjStr.put(Obj.ACHBRT, "anchor_berth");
+		ObjStr.put(Obj.UNKOBJ, "");	ObjStr.put(Obj.AIRARE, "airfield");	ObjStr.put(Obj.ACHBRT, "anchor_berth");
 		ObjStr.put(Obj.ACHARE, "anchorage"); ObjStr.put(Obj.BCNCAR, "beacon_cardinal");	ObjStr.put(Obj.BCNISD, "beacon_isolated_danger");
 		ObjStr.put(Obj.BCNLAT, "beacon_lateral");	ObjStr.put(Obj.BCNSAW, "beacon_safe_water"); ObjStr.put(Obj.BCNSPP, "beacon_special_purpose");
@@ -124,6 +124,5 @@
 		ObjStr.put(Obj.SMCFAC, "small_craft_facility");	ObjStr.put(Obj.SOUNDG, "sounding");	ObjStr.put(Obj.SPRING, "spring");	ObjStr.put(Obj.SQUARE, "square");
 		ObjStr.put(Obj.STSLNE, "territorial_baseline");	ObjStr.put(Obj.SUBTLN, "submarine_transit_lane");	ObjStr.put(Obj.SWPARE, "swept_area");
-		ObjStr.put(Obj.TESARE, "territorial_area");	ObjStr.put(Obj.TS_PRH, "");	ObjStr.put(Obj.TS_PNH, "");	ObjStr.put(Obj.TS_PAD, "");	ObjStr.put(Obj.TS_TIS, "");
-		ObjStr.put(Obj.T_HMON, "");	ObjStr.put(Obj.T_NHMN, "");	ObjStr.put(Obj.T_TIMS, "");	ObjStr.put(Obj.TIDEWY, "tideway"); ObjStr.put(Obj.TOPMAR, "topmark");
+		ObjStr.put(Obj.TESARE, "territorial_area");	ObjStr.put(Obj.TIDEWY, "tideway"); ObjStr.put(Obj.TOPMAR, "topmark");
 		ObjStr.put(Obj.TSELNE, "separation_line"); ObjStr.put(Obj.TSSBND, "separation_boundary");	ObjStr.put(Obj.TSSCRS, "separation_crossing");
 		ObjStr.put(Obj.TSSLPT, "separation_lane"); ObjStr.put(Obj.TSSRON, "separation_roundabout");	ObjStr.put(Obj.TSEZNE, "separation_zone"); ObjStr.put(Obj.TUNNEL, "tunnel");
@@ -135,5 +134,5 @@
 		ObjStr.put(Obj.BOYWTW, "buoy_waterway"); ObjStr.put(Obj.REFDMP, "refuse_dump"); ObjStr.put(Obj.RTPLPT, "route_planning_point"); ObjStr.put(Obj.TERMNL, "terminal");
 		ObjStr.put(Obj.TRNBSN, "turning_basin"); ObjStr.put(Obj.WTWARE, "waterway_area"); ObjStr.put(Obj.WTWGAG, "waterway_gauge"); ObjStr.put(Obj.TISDGE, "time_schedule");
-		ObjStr.put(Obj.VEHTRF, "vehicle_transfer"); ObjStr.put(Obj.EXCNST, "exceptional_structure"); ObjStr.put(Obj.LG_SDM, ""); ObjStr.put(Obj.LG_VSP, "");
+		ObjStr.put(Obj.VEHTRF, "vehicle_transfer"); ObjStr.put(Obj.EXCNST, "exceptional_structure");
 		ObjStr.put(Obj.MPAARE, "protected_area"); ObjStr.put(Obj.LITMAJ, "light_major"); ObjStr.put(Obj.LITMIN, "light_minor"); ObjStr.put(Obj.M_COVR, "coverage");
 	}
Index: applications/editors/josm/plugins/smed2/src/smed2/Smed2.java
===================================================================
--- applications/editors/josm/plugins/smed2/src/smed2/Smed2.java	(revision 30233)
+++ applications/editors/josm/plugins/smed2/src/smed2/Smed2.java	(revision 30269)
@@ -1,2 +1,11 @@
+/* Copyright 2013 Malcolm Herring
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.
+ */
+
 package smed2;
 
