Index: /applications/editors/josm/plugins/smed2/js57toosm/src/js57toosm/Js57toosm.java
===================================================================
--- /applications/editors/josm/plugins/smed2/js57toosm/src/js57toosm/Js57toosm.java	(revision 30281)
+++ /applications/editors/josm/plugins/smed2/js57toosm/src/js57toosm/Js57toosm.java	(revision 30282)
@@ -11,11 +11,10 @@
 
 import java.io.*;
-import java.util.Iterator;
-import java.util.Map;
+import java.util.*;
 
 import s57.S57map.Prim;
 import s57.S57obj;
+import s57.S57obj.*;
 import s57.S57att;
-import s57.S57obj.Obj;
 import s57.S57att.*;
 import s57.S57val;
@@ -57,4 +56,6 @@
 		long objl = 0;
 		double minlat = 90, minlon = 180, maxlat = -90, maxlon = -180;
+		
+		HashMap<Long, Boolean> done = new HashMap<Long, Boolean>();
 
 		while (in.read(leader) == 24) {
@@ -113,5 +114,7 @@
 							long attl = (long) S57dat.getSubf(S57subf.ATTL);
 							String atvl = (String) S57dat.getSubf(S57subf.ATVL);
-							map.newAtt(attl, atvl);
+							if (!atvl.isEmpty()) {
+								map.newAtt(attl, atvl);
+							}
 						} while (S57dat.more());
 						break;
@@ -225,11 +228,14 @@
 							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++);
+								if (!done.containsKey(ref)) {
+									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");
+									done.put(ref, true);
+								}
+								ref++;
 							}
 						}
@@ -252,7 +258,7 @@
 									long ref = git.nextRef();
 									Snode node = map.nodes.get(ref);
-									if (node != null) {
+									if (!done.containsKey(ref)) {
 										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);
+										done.put(ref, true);
 									}
 								}
@@ -273,4 +279,5 @@
 							}
 							out.format("  </way>%n");
+							done.put(way, true);
 						}
 					} else if (feature.geom.prim == Pflag.AREA) {
@@ -283,7 +290,7 @@
 									long ref = git.nextRef();
 									Snode node = map.nodes.get(ref);
-									if (node != null) {
+									if (!done.containsKey(ref)) {
 										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);
+										done.put(ref, true);
 									}
 								}
@@ -292,23 +299,34 @@
 						git = map.new GeomIterator(feature.geom);
 						while (git.hasComp()) {
-							long way = git.nextComp();
-							out.format("  <way id='%d' version='1'>%n", -way);
-							while (git.hasEdge()) {
-								git.nextEdge();
-								while (git.hasNode()) {
-									long ref = git.nextRef();
-									out.format("    <nd ref='%d'/>%n", -ref);
-								}
-							}
-							out.format("  </way>%n");
+							git.nextComp();
+							while (git.hasEdge()) {
+								long way = git.nextEdge();
+								if (!done.containsKey(way)) {
+									out.format("  <way id='%d' version='1'>%n", -way);
+									while (git.hasNode()) {
+										long ref = git.nextRef(true);
+										out.format("    <nd ref='%d'/>%n", -ref);
+									}
+									out.format("  </way>%n");
+									done.put(way, true);
+								}
+							}
 						}
 						out.format("  <relation id='%d' version='1'>%n", -map.ref++);
 						out.format("    <tag k='type' v='multipolygon'/>%n");
-						int i = 0;
-						for (Comp comp : feature.geom.refs) {
-							if (i++ < feature.geom.outers) {
-								out.format("    <member type='way' ref='%d' role='outer'/>%n", -comp.ref);
-							} else {
-								out.format("    <member type='way' ref='%d' role='inner'/>%n", -comp.ref);
+						git = map.new GeomIterator(feature.geom);
+						int outers = feature.geom.refs.get(0).size;
+if (feature.geom.inners != 0){
+	int x=0;
+}
+						while (git.hasComp()) {
+							git.nextComp();
+							while (git.hasEdge()) {
+								long way = git.nextEdge();
+								if (outers-- > 0) {
+									out.format("    <member type='way' ref='%d' role='outer'/>%n", -way);
+								} else {
+									out.format("    <member type='way' ref='%d' role='inner'/>%n", -way);
+								}
 							}
 						}
Index: /applications/editors/josm/plugins/smed2/src/s57/S57map.java
===================================================================
--- /applications/editors/josm/plugins/smed2/src/s57/S57map.java	(revision 30281)
+++ /applications/editors/josm/plugins/smed2/src/s57/S57map.java	(revision 30282)
@@ -316,10 +316,21 @@
 				feature.geom.refs.add(comp);
 				ListIterator<S57map.Prim> ite = feature.geom.elems.listIterator();
+				long first = 0;
 				while (ite.hasNext()) {
 					Prim prim = ite.next();
-					if (prim.outer) {
-						comp.size++;
-						
+					Edge edge = edges.get(prim.id);
+					if (!prim.outer) {
+						if (first == 0) {
+							feature.geom.inners++;
+							comp = new Comp(ref++, 0);
+							feature.geom.refs.add(comp);
+							first = edge.first;
+						} else {
+							if (edge.last == first) {
+								first = 0;
+							}
+						}
 					}
+					comp.size++;
 				}
 			}
@@ -609,11 +620,15 @@
 		}
 		
-		public long nextRef() {
+		public long nextRef(boolean all) {
 			long ref = eit.nextRef();
-			if (ref == lastref) {
+			if (!all && (ref == lastref)) {
 				ref = eit.nextRef();
 			}
 			lastref = ref;
 			return ref;
+		}
+		
+		public long nextRef() {
+			return nextRef(false);
 		}
 		
Index: /applications/editors/josm/plugins/smed2/src/s57/S57obj.java
===================================================================
--- /applications/editors/josm/plugins/smed2/src/s57/S57obj.java	(revision 30281)
+++ /applications/editors/josm/plugins/smed2/src/s57/S57obj.java	(revision 30282)
@@ -131,6 +131,6 @@
 		ObjStr.put(Obj.TS_FEB, "tidal_stream");	ObjStr.put(Obj.NOTMRK, "notice");	ObjStr.put(Obj.WTWAXS, "waterway_axis"); ObjStr.put(Obj.WTWPRF, "waterway_profile");
 		ObjStr.put(Obj.BRGARE, "bridge_area"); ObjStr.put(Obj.BUNSTA, "bunker_station");	ObjStr.put(Obj.COMARE, "communication_area");	ObjStr.put(Obj.HRBBSN, "harbour_basin");
-		ObjStr.put(Obj.LOKARE, "lock_area"); ObjStr.put(Obj.LKBSPT, "lock_basin_part"); ObjStr.put(Obj.PRTARE, "port_area");	ObjStr.put(Obj.BCNWTW, "beacon_waterway");
-		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.LOKARE, "lock_area"); ObjStr.put(Obj.LKBSPT, "lock_basin_part"); ObjStr.put(Obj.PRTARE, "port_area");	ObjStr.put(Obj.BCNWTW, "beacon_lateral");
+		ObjStr.put(Obj.BOYWTW, "buoy_lateral"); 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");
