Index: plications/editors/josm/plugins/o5m/src/org/openstreetmap/josm/plugins/o5m/O5mConstants.java
===================================================================
--- /applications/editors/josm/plugins/o5m/src/org/openstreetmap/josm/plugins/o5m/O5mConstants.java	(revision 34841)
+++ 	(revision )
@@ -1,25 +1,0 @@
-// License: GPL. For details, see LICENSE file.
-package org.openstreetmap.josm.plugins.o5m;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
-
-import org.openstreetmap.josm.actions.ExtensionFileFilter;
-
-/**
- * Constants for o5m plugin.
- * @author GerdP
- *
- */
-public interface O5mConstants {
-    
-    /**
-     * File extension.
-     */
-    String EXTENSION = "o5m";
-    
-    /**
-     * File filter used in import/export dialogs.
-     */
-    ExtensionFileFilter FILE_FILTER = new ExtensionFileFilter(EXTENSION, EXTENSION, 
-            tr("OSM Server Files o5m compressed") + " (*."+EXTENSION+")");
-}
Index: /applications/editors/josm/plugins/o5m/src/org/openstreetmap/josm/plugins/o5m/io/O5mImporter.java
===================================================================
--- /applications/editors/josm/plugins/o5m/src/org/openstreetmap/josm/plugins/o5m/io/O5mImporter.java	(revision 34841)
+++ /applications/editors/josm/plugins/o5m/src/org/openstreetmap/josm/plugins/o5m/io/O5mImporter.java	(revision 34842)
@@ -1,8 +1,11 @@
 // License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.o5m.io;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
 
 import java.io.IOException;
 import java.io.InputStream;
 
+import org.openstreetmap.josm.actions.ExtensionFileFilter;
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.gui.io.importexport.OsmImporter;
@@ -11,5 +14,4 @@
 import org.openstreetmap.josm.io.IllegalDataException;
 import org.openstreetmap.josm.io.CachedFile;
-import org.openstreetmap.josm.plugins.o5m.O5mConstants;
 
 /**
@@ -19,7 +21,12 @@
  */
 public class O5mImporter extends OsmImporter {
-
+    /**
+     * File extension.
+     */
+    private static final String EXTENSION = "o5m";
+    
     public O5mImporter() {
-        super(O5mConstants.FILE_FILTER);
+        super(new ExtensionFileFilter(EXTENSION, EXTENSION, 
+                tr("OSM Server Files o5m compressed") + " (*."+EXTENSION+")"));
     }
 
Index: /applications/editors/josm/plugins/o5m/src/org/openstreetmap/josm/plugins/o5m/io/O5mReader.java
===================================================================
--- /applications/editors/josm/plugins/o5m/src/org/openstreetmap/josm/plugins/o5m/io/O5mReader.java	(revision 34841)
+++ /applications/editors/josm/plugins/o5m/src/org/openstreetmap/josm/plugins/o5m/io/O5mReader.java	(revision 34842)
@@ -21,4 +21,5 @@
 import org.openstreetmap.josm.data.osm.NodeData;
 import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
+import org.openstreetmap.josm.data.osm.PrimitiveData;
 import org.openstreetmap.josm.data.osm.RelationData;
 import org.openstreetmap.josm.data.osm.RelationMemberData;
@@ -40,5 +41,5 @@
  */
 public class O5mReader extends AbstractReader {
-    private IllegalDataException exception = null;
+    private IllegalDataException exception;
     private boolean discourageUpload;
     
@@ -77,5 +78,5 @@
     private static final int MAX_STRING_PAIR_SIZE = 250 + 2;
     private static final String[] REL_REF_TYPES = {"node", "way", "relation", "?"};
-    private static final double FACTOR = 1d/1000000000; // used with 100*<Val>*FACTOR 
+    private static final double FACTOR = 1d/1_000_000_000; // used with 100*<Val>*FACTOR 
 
     private BufferedInputStream fis;
@@ -86,5 +87,5 @@
 
     private byte[] ioBuf;
-    private int ioPos;
+    private int ioBufPos;
     // the o5m string table
     private String[][] stringTable;
@@ -114,5 +115,5 @@
         this.cnvBuffer = new byte[4000]; // OSM data should not contain string pairs with length > 512
         this.ioBuf = new byte[8192];
-        this.ioPos = 0;
+        this.ioBufPos = 0;
         this.stringPair = new String[2];
         this.lastRef = new long[3];
@@ -166,15 +167,5 @@
                 case TIMESTAMP_DATASET:
                 case HEADER_DATASET:
-                    if (bytesToRead > ioBuf.length) {
-                        ioBuf = new byte[bytesToRead+100];
-                    }
-                    int bytesRead = 0;
-                    int neededBytes = bytesToRead;
-                    while (neededBytes > 0) {
-                        bytesRead += is.read(ioBuf, bytesRead, neededBytes);
-                        neededBytes -= bytesRead;
-                    } 
-                    ioPos = 0;
-                    is = new ByteArrayInputStream(ioBuf, 0, bytesToRead);
+                    is = fillByteArray();
                     break;                    
                 default: break;    
@@ -196,4 +187,18 @@
     }
 
+    private InputStream fillByteArray() throws IOException {
+        if (bytesToRead > ioBuf.length) {
+            ioBuf = new byte[bytesToRead + 100];
+        }
+        int bytesRead = 0;
+        int neededBytes = bytesToRead;
+        while (neededBytes > 0) {
+            bytesRead += is.read(ioBuf, bytesRead, neededBytes);
+            neededBytes -= bytesRead;
+        }
+        ioBufPos = 0;
+        return new ByteArrayInputStream(ioBuf, 0, bytesToRead);
+    }
+
     /**
      * read (and ignore) the file timestamp data set
@@ -230,4 +235,17 @@
         } else {
             Logging.error("Invalid Bounds: " + b);
+        }
+    }
+
+    private void setMeta(PrimitiveData pd) throws IllegalDataException {
+        pd.setVersion(version == 0 ? 1 : version);
+        checkChangesetId(lastChangeSet);
+        pd.setChangesetId((int) lastChangeSet);
+        // User id
+        if (lastTs != 0) {
+            checkTimestamp(lastTs);
+            pd.setTimestamp(new Date(lastTs * 1000));
+            if (osmUser != null)
+                pd.setUser(osmUser);
         }
     }
@@ -257,17 +275,8 @@
                 discourageUpload = true;
             NodeData nd = new NodeData(lastNodeId);
-            nd.setVersion(version == 0 ? 1 : version);
             nd.setCoor(new LatLon(flat, flon).getRoundedToOsmPrecision());
-
             checkCoordinates(nd.getCoor());
-            checkChangesetId(lastChangeSet);
-            nd.setChangesetId((int) lastChangeSet);
-            // User id
-            if (lastTs != 0) {
-                checkTimestamp(lastTs);
-                nd.setTimestamp(new Date(lastTs * 1000));
-                if (osmUser != null)
-                    nd.setUser(osmUser);
-            }
+            setMeta(nd);
+
             if (bytesToRead > 0) {
                 Map<String, String> keys = readTags();
@@ -279,5 +288,4 @@
             exception = e;
         }
-
     }
 
@@ -299,14 +307,5 @@
                 discourageUpload = true;
             final WayData wd = new WayData(lastWayId);
-            wd.setVersion(version == 0 ? 1 : version);
-            checkChangesetId(lastChangeSet);
-            wd.setChangesetId((int) lastChangeSet);
-            // User id
-            if (lastTs != 0) {
-                checkTimestamp(lastTs);
-                wd.setTimestamp(new Date(lastTs * 1000));
-                if (osmUser != null)
-                    wd.setUser(osmUser);
-            }
+            setMeta(wd);
 
             long refSize = readUnsignedNum32();
@@ -345,13 +344,5 @@
                 discourageUpload = true;
             final RelationData rel = new RelationData(lastRelId);
-            rel.setVersion(version == 0 ? 1 : version);
-            checkChangesetId(lastChangeSet);
-            rel.setChangesetId((int) lastChangeSet);
-            if (lastTs != 0) {
-                checkTimestamp(lastTs);
-                rel.setTimestamp(new Date(lastTs * 1000));
-                if (osmUser != null)
-                    rel.setUser(osmUser);
-            }
+            setMeta(rel);
 
             long refSize = readUnsignedNum32();
@@ -447,6 +438,6 @@
                 stringPair[0] = "";
             else {
-                stringPair[0] = Long.toString(uidNum);
-                ioPos++; // skip terminating zero from uid
+                stringPair[0] = Long.toUnsignedString(uidNum);
+                ioBufPos++; // skip terminating zero from uid
                 --bytesToRead;
             }
@@ -455,5 +446,5 @@
             stringPair[1] = null;
             while (stringPair[1] == null) {
-                final int b = ioBuf[ioPos++];
+                final int b = ioBuf[ioBufPos++];
                 --bytesToRead;
                 cnvBuffer[buffPos++] = (byte) b;
@@ -483,5 +474,5 @@
         int stringRef = readUnsignedNum32();
         if (stringRef == 0) {
-            refType = ioBuf[ioPos++] - 0x30;
+            refType = ioBuf[ioBufPos++] - 0x30;
             --bytesToRead;
 
@@ -494,5 +485,5 @@
             stringPair[1] = null;
             while (stringPair[1] == null) {
-                final int b = ioBuf[ioPos++];
+                final int b = ioBuf[ioBufPos++];
                 --bytesToRead;
                 cnvBuffer[buffPos++] = (byte) b;
@@ -528,5 +519,5 @@
             int start = 0;
             while (cnt < 2) {
-                final int b = ioBuf[ioPos++];
+                final int b = ioBuf[ioBufPos++];
                 --bytesToRead;
                 cnvBuffer[buffPos++] = (byte) b;
@@ -571,27 +562,5 @@
      */
     private int readSignedNum32() {
-        int result;
-        int b = ioBuf[ioPos++];
-        --bytesToRead;
-        result = b;
-        if ((b & 0x80) == 0) {  // just one byte
-            if ((b & 0x01) == 1)
-                return -1-(result >> 1); 
-            return result >> 1;
-        }
-        int sign = b & 0x01;
-        result = (result & 0x7e) >> 1;
-        int shift = 6;
-        while (((b = ioBuf[ioPos++]) & 0x80) != 0) { // more bytes will follow
-            --bytesToRead;
-            result += (b & 0x7f) << shift;
-            shift += 7;
-        }
-        --bytesToRead;
-        result += b << shift;
-        if (sign == 1) // negative
-            return -1 - result;
-        return result;
-
+        return (int) readSignedNum64();
     }
 
@@ -602,5 +571,5 @@
     private long readSignedNum64() {
         long result;
-        int b = ioBuf[ioPos++];
+        int b = ioBuf[ioBufPos++];
         --bytesToRead;
         result = b;
@@ -613,5 +582,5 @@
         result = (result & 0x7e) >> 1;
         int shift = 6;
-        while (((b = ioBuf[ioPos++]) & 0x80) != 0) { // more bytes will follow
+        while (((b = ioBuf[ioBufPos++]) & 0x80) != 0) { // more bytes will follow
             --bytesToRead;
             result += ((long) (b & 0x7f)) << shift;
@@ -655,5 +624,5 @@
      */
     private long readUnsignedNum64() {
-        int b = ioBuf[ioPos++];
+        int b = ioBuf[ioBufPos++];
         --bytesToRead;
         long result = b;
@@ -663,5 +632,5 @@
         result &= 0x7f;
         int shift = 7;
-        while (((b = ioBuf[ioPos++]) & 0x80) != 0) { // more bytes will follow
+        while (((b = ioBuf[ioBufPos++]) & 0x80) != 0) { // more bytes will follow
             --bytesToRead;
             result += ((long) (b & 0x7f)) << shift;
@@ -675,24 +644,8 @@
     /**
      * read a varying length unsigned number (see o5m definition)
-     * is similar to the 64 bit version.
      * @return the number as int
      */
     private int readUnsignedNum32() {
-        int b = ioBuf[ioPos++];
-        --bytesToRead;
-        int result = b;
-        if ((b & 0x80) == 0) {  // just one byte
-            return result;
-        }
-        result &= 0x7f;
-        int shift = 7;
-        while (((b = ioBuf[ioPos++]) & 0x80) != 0) { // more bytes will follow
-            --bytesToRead;
-            result += (b & 0x7f) << shift;
-            shift += 7;
-        }
-        --bytesToRead;
-        result += b << shift;
-        return result;
+        return (int) readUnsignedNum64();
     }
 
@@ -700,6 +653,7 @@
      * Exception thrown after user cancellation.
      */
-    @SuppressWarnings("serial")
     private static final class O5mParsingCancelException extends Exception implements ImportCancelException {
+        private static final long serialVersionUID = 1L;
+
         O5mParsingCancelException(String msg) {
             super(msg);
