Index: src/test/java/org/apache/jackrabbit/core/state/ChangeLogTest.java
===================================================================
--- src/test/java/org/apache/jackrabbit/core/state/ChangeLogTest.java	(revision 597523)
+++ src/test/java/org/apache/jackrabbit/core/state/ChangeLogTest.java	(working copy)
@@ -20,7 +20,6 @@
 import org.apache.jackrabbit.name.NameFactoryImpl;
 import org.apache.jackrabbit.core.PropertyId;
 import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.spi.NameFactory;
 
 import java.util.Iterator;
@@ -44,7 +43,7 @@
      */
     public void testAddDelete() throws Exception {
         PropertyId id = new PropertyId(
-                new NodeId(UUID.randomUUID()), factory.create("", "a"));
+                NodeId.randomNodeId(), factory.create("", "a"));
         ItemState state = new PropertyState(id, ItemState.STATUS_NEW, false);
 
         ChangeLog log = new ChangeLog();
@@ -64,7 +63,7 @@
      */
     public void testAddModify() throws Exception {
         PropertyId id = new PropertyId(
-                new NodeId(UUID.randomUUID()), factory.create("", "a"));
+                NodeId.randomNodeId(), factory.create("", "a"));
         ItemState state = new PropertyState(id, ItemState.STATUS_NEW, false);
 
         ChangeLog log = new ChangeLog();
@@ -86,7 +85,7 @@
         ItemState[] states = new ItemState[10];
         for (int i = 0; i < states.length; i++) {
             PropertyId id = new PropertyId(
-                    new NodeId(UUID.randomUUID()), factory.create("", "a" + i));
+                    NodeId.randomNodeId(), factory.create("", "a" + i));
             states[i] = new PropertyState(id, ItemState.STATUS_NEW, false);
         }
 
Index: src/test/java/org/apache/jackrabbit/core/version/VersionIteratorImplTest.java
===================================================================
--- src/test/java/org/apache/jackrabbit/core/version/VersionIteratorImplTest.java	(revision 597523)
+++ src/test/java/org/apache/jackrabbit/core/version/VersionIteratorImplTest.java	(working copy)
@@ -22,7 +22,6 @@
 
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.uuid.UUID;
 
 public class VersionIteratorImplTest extends TestCase {
 
@@ -60,9 +59,9 @@
 
     public void testVersionIterator() throws Exception {
 
-        InternalVersion version = new DummyInternalVersion(new InternalVersion[] {}, new NodeId(UUID.randomUUID()));
+        InternalVersion version = new DummyInternalVersion(new InternalVersion[] {}, NodeId.randomNodeId());
         for (int i = 1; i < VERSION_COUNT; i++) {
-            version = new DummyInternalVersion(new InternalVersion[] {version}, new NodeId(UUID.randomUUID()));
+            version = new DummyInternalVersion(new InternalVersion[] {version}, NodeId.randomNodeId());
         }
 
         try {
Index: src/test/java/org/apache/jackrabbit/core/xml/WorkspaceImporterTest.java
===================================================================
--- src/test/java/org/apache/jackrabbit/core/xml/WorkspaceImporterTest.java	(revision 597523)
+++ src/test/java/org/apache/jackrabbit/core/xml/WorkspaceImporterTest.java	(working copy)
@@ -24,8 +24,8 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
+import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.TestRepository;
-import org.apache.jackrabbit.uuid.UUID;
 
 import junit.framework.TestCase;
 
@@ -58,7 +58,7 @@
      */
     public void testReferenceImport() throws Exception {
         try {
-            UUID uuid = UUID.randomUUID();
+            NodeId id = NodeId.randomNodeId();
             String xml =
                 "<sv:node sv:name=\"a\""
                 + " xmlns:jcr=\"http://www.jcp.org/jcr/1.0\""
@@ -72,13 +72,13 @@
                 + "<sv:property sv:name=\"jcr:mixinTypes\" sv:type=\"Name\">"
                 + "<sv:value>mix:referenceable</sv:value></sv:property>"
                 + "<sv:property sv:name=\"jcr:uuid\" sv:type=\"String\">"
-                + "<sv:value>" + uuid + "</sv:value></sv:property>"
+                + "<sv:value>" + id + "</sv:value></sv:property>"
                 + "</sv:node>"
                 + "<sv:node sv:name=\"c\">"
                 + "<sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\">"
                 + "<sv:value>nt:unstructured</sv:value></sv:property>"
                 + "<sv:property sv:name=\"ref\" sv:type=\"Reference\">"
-                + "<sv:value>" + uuid + "</sv:value></sv:property>"
+                + "<sv:value>" + id + "</sv:value></sv:property>"
                 + "</sv:node>"
                 + "</sv:node>";
             session.getWorkspace().importXML(
Index: src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java
===================================================================
--- src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java	(revision 597523)
+++ src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java	(working copy)
@@ -78,7 +78,7 @@
                 NodeId id = it.nextNodeId();
                 log("  " + id.toString());
                 if (after != null) {
-                    assertFalse(id.getUUID().compareTo(after.getUUID()) == 0);
+                    assertFalse(id.equals(after));
                 }
                 after = id;
             }
@@ -93,20 +93,20 @@
                 while (it.hasNext()) {
                     NodeId id = it.nextNodeId();
                     log("    " + id.toString());
-                    assertFalse(id.getUUID().compareTo(after.getUUID()) == 0);
+                    assertFalse(id.equals(after));
                     after = id;
                 }
             }
 
             log("Random access");
             for (int j = 0; j < 50; j++) {
-                after = new NodeId(UUID.randomUUID());
+                after = NodeId.randomNodeId();
                 log(" bigger than: " + after);
                 it = apm.getAllNodeIds(after, 2);
                 while (it.hasNext()) {
                     NodeId id = it.nextNodeId();
                     log("    " + id.toString());
-                    assertFalse(id.getUUID().compareTo(after.getUUID()) == 0);
+                    assertFalse(id.equals(after));
                     after = id;
                 }
             }
Index: src/main/java/org/apache/jackrabbit/core/NodeId.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/NodeId.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/NodeId.java	(working copy)
@@ -21,18 +21,22 @@
 /**
  * Node identifier. An instance of this class identifies a node using its UUID.
  * Once created a node identifier instance is immutable.
+ * <p>
+ * This class is partially based on UUID code that originated from the
+ * commons-id component in the sandbox of the Apache Commons project.
  */
-public class NodeId extends ItemId {
+public class NodeId extends ItemId implements Comparable {
 
-    /** Serial version UID of this class. */
-    static final long serialVersionUID = 7380115476447060008L;
+    /**
+     * The least significant 64 bits of the uuid (bytes 8-15)
+     */
+    private final long lsb;
 
-    /** UUID of the identified node */
-    private final UUID uuid;
+    /**
+     * The most significant 64 bits of the uuid (bytes 0-7)
+     */
+    private final long msb;
 
-    /** the precalculated hashcode */
-    private final int hashCode;
-
     /**
      * Creates a node identifier instance for the identified node.
      *
@@ -42,11 +46,32 @@
         if (uuid == null) {
             throw new IllegalArgumentException("uuid can not be null");
         }
-        this.uuid = uuid;
-        this.hashCode = uuid.hashCode();
+        this.lsb = uuid.getLeastSignificantBits();
+        this.msb = uuid.getMostSignificantBits();
     }
 
     /**
+     * Creates a node identifier with the given 128 bits
+     *
+     * @param mostSignificant most significant bits
+     * @param leastSignificant least significant bits
+     */
+    public NodeId(long mostSignificant, long leastSignificant) {
+        msb = mostSignificant;
+        lsb = leastSignificant;
+    }
+
+    /**
+     * Creates a node identifier from the given array of 16 bytes.
+     *
+     * @param uuid byte array
+     * @throws IllegalArgumentException if the array length is not 16
+     */
+    public NodeId(byte[] uuid) throws IllegalArgumentException {
+        this(new UUID(uuid));
+    }
+
+    /**
      * Returns <code>true</code> as this class represents a node identifier,
      * not a property identifier.
      *
@@ -58,31 +83,98 @@
     }
 
     /**
-     * Returns the UUID of the identified node.
+     * Returns the least significant bits stored in the uuid's internal structure.
      *
-     * @return node UUID
+     * @return the least significant bits stored in the uuid's internal structure.
      */
-    public UUID getUUID() {
-        return uuid;
+    public long getLeastSignificantBits() {
+        return lsb;
     }
 
     /**
-     * Returns a <code>NodeId</code> holding the value of the specified
-     * string. The string must be in the format returned by the
-     * <code>NodeId.toString()</code> method.
+     * Returns the most significant bits stored in the uuid's internal structure.
      *
-     * @param s a <code>String</code> containing the <code>NodeId</code>
-     *          representation to be parsed.
-     * @return the <code>NodeId</code> represented by the argument
-     * @throws IllegalArgumentException if the specified string can not be parsed
-     *                                  as a <code>NodeId</code>.
-     * @see #toString()
+     * @return the most significant bits stored in the uuid's internal structure.
      */
-    public static NodeId valueOf(String s) throws IllegalArgumentException {
-        if (s == null) {
-            throw new IllegalArgumentException("invalid NodeId literal");
+    public long getMostSignificantBits() {
+        return msb;
+    }
+
+    /**
+     * Returns a copy of the byte values contained in this UUID.
+     *
+     * @return a copy of the byte values contained in this UUID.
+     */
+    public byte[] getRawBytes() {
+        byte[] b = new byte[UUID.UUID_BYTE_LENGTH];
+        long n = msb;
+        b[7] = (byte) n;
+        n >>>= 8;
+        b[6] = (byte) n;
+        n >>>= 8;
+        b[5] = (byte) n;
+        n >>>= 8;
+        b[4] = (byte) n;
+        n >>>= 8;
+        b[3] = (byte) n;
+        n >>>= 8;
+        b[2] = (byte) n;
+        n >>>= 8;
+        b[1] = (byte) n;
+        n >>>= 8;
+        b[0] = (byte) n;
+
+        n = lsb;
+        b[15] = (byte) n;
+        n >>>= 8;
+        b[14] = (byte) n;
+        n >>>= 8;
+        b[13] = (byte) n;
+        n >>>= 8;
+        b[12] = (byte) n;
+        n >>>= 8;
+        b[11] = (byte) n;
+        n >>>= 8;
+        b[10] = (byte) n;
+        n >>>= 8;
+        b[9] = (byte) n;
+        n >>>= 8;
+        b[8] = (byte) n;
+
+        return b;
+    }
+
+    /**
+     * Creates a node identifier from the given UUID string.
+     *
+     * @param uuid UUID string
+     * @throws IllegalArgumentException if the string format is invalid
+     */
+    public static NodeId valueOf(String uuid) throws IllegalArgumentException {
+        return new NodeId(new UUID(uuid));
+    }
+
+    /**
+     * Returns a new node identifier, based upon Random bits.
+     *
+     * @return a new node identifier
+     */
+    public static NodeId randomNodeId() {
+        return new NodeId(UUID.randomUUID());
+    }
+
+    /**
+     * Compares two node identifiers.
+     */
+    public int compareTo(Object compareTo) throws ClassCastException {
+        final NodeId id = (NodeId) compareTo;
+        if (msb == id.msb) {
+            if (lsb == id.lsb) {
+                return 0;
+            }
+            return lsb > id.lsb ? 1 : -1;
         }
-        return new NodeId(new UUID(s));
+        return msb > id.msb ? 1 : -1;
     }
 
     //-------------------------------------------< java.lang.Object overrides >
@@ -94,7 +186,8 @@
             return true;
         }
         if (obj instanceof NodeId) {
-            return uuid.equals(((NodeId) obj).uuid);
+            NodeId that = (NodeId) obj;
+            return lsb == that.lsb && msb == that.msb;
         }
         return false;
     }
@@ -105,7 +198,7 @@
      * Returns the same as <code>this.getUUID().toString()</code>
      */
     public String toString() {
-        return uuid.toString();
+        return new UUID(msb, lsb).toString();
     }
 
     /**
@@ -114,6 +207,7 @@
      * Returns the same as <code>this.getUUID().hashCode()</code>
      */
     public int hashCode() {
-        return hashCode;
+        return (int) ((msb >>> 32) ^ msb ^ (lsb >>> 32) ^ lsb);
     }
+
 }
Index: src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java	(working copy)
@@ -168,7 +168,7 @@
      */
     private String buildNodeFolderPath(NodeId id) {
         StringBuffer sb = new StringBuffer();
-        char[] chars = id.getUUID().toString().toCharArray();
+        char[] chars = id.toString().toCharArray();
         int cnt = 0;
         for (int i = 0; i < nodePathTemplate.length(); i++) {
             char ch = nodePathTemplate.charAt(i);
@@ -223,7 +223,7 @@
             throw new ItemStateException(msg);
         }
         // check uuid
-        if (!state.getNodeId().getUUID().toString().equals(walker.getAttribute(UUID_ATTRIBUTE))) {
+        if (!state.getNodeId().toString().equals(walker.getAttribute(UUID_ATTRIBUTE))) {
             String msg = "invalid serialized state: uuid mismatch";
             log.debug(msg);
             throw new ItemStateException(msg);
@@ -568,8 +568,8 @@
 
                 writer.write("<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>\n");
                 writer.write("<" + NODE_ELEMENT + " "
-                        + UUID_ATTRIBUTE + "=\"" + id.getUUID() + "\" "
-                        + PARENTUUID_ATTRIBUTE + "=\"" + (state.getParentId() == null ? "" : state.getParentId().getUUID().toString()) + "\" "
+                        + UUID_ATTRIBUTE + "=\"" + id + "\" "
+                        + PARENTUUID_ATTRIBUTE + "=\"" + (state.getParentId() == null ? "" : state.getParentId().toString()) + "\" "
                         + DEFINITIONID_ATTRIBUTE + "=\"" + state.getDefinitionId().toString() + "\" "
                         + MODCOUNT_ATTRIBUTE + "=\"" + state.getModCount() + "\" "
                         + NODETYPE_ATTRIBUTE + "=\"" + Text.encodeIllegalXMLCharacters(state.getNodeTypeName().toString()) + "\">\n");
@@ -602,7 +602,7 @@
                     NodeState.ChildNodeEntry entry = (NodeState.ChildNodeEntry) iter.next();
                     writer.write("\t\t<" + NODE_ELEMENT + " "
                             + NAME_ATTRIBUTE + "=\"" + Text.encodeIllegalXMLCharacters(entry.getName().toString()) + "\" "
-                            + UUID_ATTRIBUTE + "=\"" + entry.getId().getUUID().toString() + "\">\n");
+                            + UUID_ATTRIBUTE + "=\"" + entry.getId() + "\">\n");
                     writer.write("\t\t</" + NODE_ELEMENT + ">\n");
                 }
                 writer.write("\t</" + NODES_ELEMENT + ">\n");
@@ -656,7 +656,7 @@
                 writer.write("<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>\n");
                 writer.write("<" + PROPERTY_ELEMENT + " "
                         + NAME_ATTRIBUTE + "=\"" + Text.encodeIllegalXMLCharacters(state.getName().toString()) + "\" "
-                        + PARENTUUID_ATTRIBUTE + "=\"" + state.getParentId().getUUID() + "\" "
+                        + PARENTUUID_ATTRIBUTE + "=\"" + state.getParentId() + "\" "
                         + MULTIVALUED_ATTRIBUTE + "=\"" + Boolean.toString(state.isMultiValued()) + "\" "
                         + DEFINITIONID_ATTRIBUTE + "=\"" + state.getDefinitionId().toString() + "\" "
                         + MODCOUNT_ATTRIBUTE + "=\"" + state.getModCount() + "\" "
Index: src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java	(working copy)
@@ -40,7 +40,6 @@
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.NodeIdIterator;
 import org.apache.jackrabbit.core.PropertyId;
-import org.apache.jackrabbit.uuid.UUID;
 
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
@@ -686,10 +685,10 @@
                 NodeId id;
                 Blob blob;
                 if (getStorageModel() == SM_BINARY_KEYS) {
-                    id = new NodeId(new UUID(rs.getBytes(1)));
+                    id = new NodeId(rs.getBytes(1));
                     blob = rs.getBlob(2);
                 } else {
-                    id = new NodeId(new UUID(rs.getLong(1), rs.getLong(2)));
+                    id = new NodeId(rs.getLong(1), rs.getLong(2));
                     blob = rs.getBlob(3);
                 }
                 din = new DataInputStream(blob.getBinaryStream());
@@ -708,14 +707,14 @@
                         try {
                             NodePropBundle child = loadBundle(entry.getId());
                             if (child == null) {
-                                log.error("NodeState " + id.getUUID() + " references inexistent child " + entry.getName() + " with id " + entry.getId().getUUID());
+                                log.error("NodeState " + id + " references inexistent child " + entry.getName() + " with id " + entry.getId());
                                 missingChildren.add(entry);
                             } else {
                                 NodeId cp = child.getParentId();
                                 if (cp == null) {
                                     log.error("ChildNode has invalid parent uuid: null");
                                 } else if (!cp.equals(id)) {
-                                    log.error("ChildNode has invalid parent uuid: " + cp + " (instead of " + id.getUUID() + ")");
+                                    log.error("ChildNode has invalid parent uuid: " + cp + " (instead of " + id + ")");
                                 }
                             }
                         } catch (ItemStateException e) {
@@ -827,56 +826,58 @@
      * <code>pos</code> and returns the number of key parameters + pos.
      *
      * @param stmt the statement
-     * @param uuid the uuid of the key
+     * @param id the id of the key
      * @param pos the position of the key parameter
      * @return the number of key parameters + <code>pos</code>
      * @throws SQLException if an SQL error occurs.
      */
-    protected int setKey(PreparedStatement stmt, UUID uuid, int pos)
+    protected int setKey(PreparedStatement stmt, NodeId id, int pos)
             throws SQLException {
         if (getStorageModel() == SM_BINARY_KEYS) {
-            stmt.setBytes(pos++, uuid.getRawBytes());
+            stmt.setBytes(pos++, id.getRawBytes());
         } else {
-            stmt.setLong(pos++, uuid.getMostSignificantBits());
-            stmt.setLong(pos++, uuid.getLeastSignificantBits());
+            stmt.setLong(pos++, id.getMostSignificantBits());
+            stmt.setLong(pos++, id.getLeastSignificantBits());
         }
         return pos;
     }
 
     /**
      * Constructs a parameter list for a PreparedStatement
-     * for the given UUID.
+     * for the given node id.
      *
-     * @param uuid the uuid
+     * @param id the node id
      * @return a list of Objects
      */
-    protected Object[] getKey(UUID uuid) {
+    protected Object[] getKey(NodeId id) {
         if (getStorageModel() == SM_BINARY_KEYS) {
-            return new Object[]{uuid.getRawBytes()};
+            return new Object[]{ id.getRawBytes() };
         } else {
-            return new Object[]{new Long(uuid.getMostSignificantBits()),
-                    new Long(uuid.getLeastSignificantBits())};
+            return new Object[]{
+                    new Long(id.getMostSignificantBits()),
+                    new Long(id.getLeastSignificantBits())
+            };
         }
     }
 
     /**
      * Creates a parameter array for an SQL statement that needs
-     * (i) a UUID, and (2) another parameter.
+     * (i) a node id, and (2) another parameter.
      *
-     * @param uuid the UUID
+     * @param id the node id
      * @param p the other parameter
      * @param before whether the other parameter should be before the uuid parameter
      * @return an Object array that represents the parameters
      */
-    protected Object[] createParams(UUID uuid, Object p, boolean before) {
+    protected Object[] createParams(NodeId id, Object p, boolean before) {
 
         // Create the key
         List key = new ArrayList();
         if (getStorageModel() == SM_BINARY_KEYS) {
-            key.add(uuid.getRawBytes());
+            key.add(id.getRawBytes());
         } else {
-            key.add(new Long(uuid.getMostSignificantBits()));
-            key.add(new Long(uuid.getLeastSignificantBits()));
+            key.add(new Long(id.getMostSignificantBits()));
+            key.add(new Long(id.getLeastSignificantBits()));
         }
 
         // Create the parameters
@@ -899,17 +900,15 @@
             throws ItemStateException, RepositoryException {
         ResultSet rs = null;
         try {
-            UUID lowUuid;
+            NodeId lowId = bigger;
             Object[] keys;
             String sql;
             if (bigger == null) {
                 sql = bundleSelectAllIdsSQL;
-                lowUuid = null;
                 keys = new Object[0];
             } else {
                 sql = bundleSelectAllIdsFromSQL;
-                lowUuid = bigger.getUUID();
-                keys = getKey(lowUuid);
+                keys = getKey(bigger);
             }
             if (maxCount > 0) {
                 // get some more rows, in case the first row is smaller
@@ -922,22 +921,20 @@
             rs = stmt.getResultSet();
             ArrayList result = new ArrayList();
             while ((maxCount == 0 || result.size() < maxCount) && rs.next()) {
-                UUID current;
+                NodeId current;
                 if (getStorageModel() == SM_BINARY_KEYS) {
-                    current = new UUID(rs.getBytes(1));
+                    current = new NodeId(rs.getBytes(1));
                 } else {
-                    long high = rs.getLong(1);
-                    long low = rs.getLong(2);
-                    current = new UUID(high, low);
+                    current = new NodeId(rs.getLong(1), rs.getLong(2));
                 }
-                if (lowUuid != null) {
+                if (lowId != null) {
                     // skip the keys that are smaller or equal (see above, maxCount += 10)
-                    if (current.compareTo(lowUuid) <= 0) {
+                    if (current.compareTo(lowId) <= 0) {
                         continue;
                     }
                 }
                 result.add(current);
-            }        
+            }
             ListNodeIdIterator it = new ListNodeIdIterator(result);
             return it;
         } catch (SQLException e) {
@@ -957,7 +954,7 @@
         ResultSet rs = null;
         InputStream in = null;
         try {
-            Statement stmt = connectionManager.executeStmt(bundleSelectSQL, getKey(id.getUUID()));
+            Statement stmt = connectionManager.executeStmt(bundleSelectSQL, getKey(id));
             rs = stmt.getResultSet();
             if (!rs.next()) {
                 return null;
@@ -991,7 +988,7 @@
     protected synchronized boolean existsBundle(NodeId id) throws ItemStateException {
         ResultSet rs = null;
         try {
-            Statement stmt = connectionManager.executeStmt(bundleSelectSQL, getKey(id.getUUID()));
+            Statement stmt = connectionManager.executeStmt(bundleSelectSQL, getKey(id));
             rs = stmt.getResultSet();
             // a bundle exists, if the result has at least one entry
             return rs.next();
@@ -1015,7 +1012,7 @@
             dout.close();
 
             String sql = bundle.isNew() ? bundleInsertSQL : bundleUpdateSQL;
-            Object[] params = createParams(bundle.getId().getUUID(), out.toByteArray(), true);
+            Object[] params = createParams(bundle.getId(), out.toByteArray(), true);
             connectionManager.executeStmt(sql, params);
         } catch (Exception e) {
             String msg = "failed to write bundle: " + bundle.getId();
@@ -1029,7 +1026,7 @@
      */
     protected synchronized void destroyBundle(NodePropBundle bundle) throws ItemStateException {
         try {
-            connectionManager.executeStmt(bundleDeleteSQL, getKey(bundle.getId().getUUID()));
+            connectionManager.executeStmt(bundleDeleteSQL, getKey(bundle.getId()));
             // also delete all
             bundle.removeAllProperties();
         } catch (Exception e) {
@@ -1055,7 +1052,7 @@
         InputStream in = null;
         try {
             Statement stmt = connectionManager.executeStmt(
-                    nodeReferenceSelectSQL, getKey(targetId.getTargetId().getUUID()));
+                    nodeReferenceSelectSQL, getKey(targetId.getTargetId()));
             rs = stmt.getResultSet();
             if (!rs.next()) {
                 throw new NoSuchItemStateException(targetId.toString());
@@ -1103,7 +1100,7 @@
             // serialize references
             Serializer.serialize(refs, out);
 
-            Object[] params = createParams(refs.getTargetId().getUUID(), out.toByteArray(), true);
+            Object[] params = createParams(refs.getTargetId(), out.toByteArray(), true);
             connectionManager.executeStmt(sql, params);
 
             // there's no need to close a ByteArrayOutputStream
@@ -1124,8 +1121,8 @@
         }
 
         try {
-            connectionManager.executeStmt(nodeReferenceDeleteSQL,
-                    getKey(refs.getTargetId().getUUID()));
+            connectionManager.executeStmt(
+                    nodeReferenceDeleteSQL, getKey(refs.getTargetId()));
         } catch (Exception e) {
             if (e instanceof NoSuchItemStateException) {
                 throw (NoSuchItemStateException) e;
@@ -1146,8 +1143,8 @@
 
         ResultSet rs = null;
         try {
-            Statement stmt = connectionManager.executeStmt(nodeReferenceSelectSQL,
-                    getKey(targetId.getTargetId().getUUID()));
+            Statement stmt = connectionManager.executeStmt(
+                    nodeReferenceSelectSQL, getKey(targetId.getTargetId()));
             rs = stmt.getResultSet();
 
             // a reference exists if the result has at least one entry
@@ -1423,7 +1420,7 @@
             if (!hasNext()) {
                 throw new NoSuchElementException();
             }
-            return new NodeId((UUID) list.get(pos++));
+            return (NodeId) list.get(pos++);
         }        
 
         public boolean hasNext() {
Index: src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java	(working copy)
@@ -37,7 +37,6 @@
 import org.apache.jackrabbit.core.state.NodeReferencesId;
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
 import org.apache.jackrabbit.core.state.NodeReferences;
-import org.apache.jackrabbit.uuid.UUID;
 
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
@@ -690,7 +689,7 @@
             throws ItemStateException {
         ArrayList list = new ArrayList();
         try {
-            getListRecursive(list, "", bigger == null ? null : bigger.getUUID(), maxCount);
+            getListRecursive(list, "", bigger, maxCount);
             return new FileNodeIdIterator(list);
         } catch (FileSystemException e) {
             String msg = "failed to read node list: " + bigger + ": " + e;
@@ -702,7 +701,7 @@
     /**
      * {@inheritDoc}
      */    
-    protected UUID getUUIDFromFileName(String fileName) {
+    protected NodeId getNodeIdFromFileName(String fileName) {
         StringBuffer buff = new StringBuffer(35);
         if (!fileName.endsWith("." + NODEFILENAME)) {
             return null;
@@ -720,11 +719,10 @@
                 }
             }
         }
-        String u = buff.toString();
-        return new UUID(u);
+        return NodeId.valueOf(buff.toString());
     }    
     
-    private void getListRecursive(ArrayList list, String path, UUID bigger,
+    private void getListRecursive(ArrayList list, String path, NodeId bigger,
             int maxCount) throws FileSystemException {
         if (maxCount > 0 && list.size() >= maxCount) {
             return;
@@ -733,15 +731,14 @@
         Arrays.sort(files);
         for (int i = 0; i < files.length; i++) {
             String f = files[i];
-            UUID u = getUUIDFromFileName(path + FileSystem.SEPARATOR + f);
-            if (u == null) {
+            NodeId id = getNodeIdFromFileName(path + FileSystem.SEPARATOR + f);
+            if (id == null) {
                 continue;
             }
-            if (bigger != null && bigger.toString().compareTo(u.toString()) < 0) {
+            if (bigger != null && bigger.toString().compareTo(id.toString()) < 0) {
                 continue;
             }
-            NodeId n = new NodeId(u);
-            list.add(n);
+            list.add(id);
             if (maxCount > 0 && list.size() >= maxCount) {
                 return;
             }
Index: src/main/java/org/apache/jackrabbit/core/persistence/bundle/PostgreSQLPersistenceManager.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/persistence/bundle/PostgreSQLPersistenceManager.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/persistence/bundle/PostgreSQLPersistenceManager.java	(working copy)
@@ -91,7 +91,7 @@
     protected synchronized NodePropBundle loadBundle(NodeId id)
             throws ItemStateException {
         try {
-            Statement stmt = connectionManager.executeStmt(bundleSelectSQL, getKey(id.getUUID()));
+            Statement stmt = connectionManager.executeStmt(bundleSelectSQL, getKey(id));
             ResultSet rs = stmt.getResultSet();
             try {
                 if (rs.next()) {
Index: src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java	(working copy)
@@ -28,7 +28,6 @@
 import org.apache.jackrabbit.core.nodetype.NodeDefId;
 import org.apache.jackrabbit.core.nodetype.PropDefId;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.name.NameFactoryImpl;
 
 import java.io.DataInputStream;
@@ -164,10 +163,10 @@
             return false;
         }
         try {
-            UUID parentUuid = readUUID(in);
-            log.info("ParentUUID: " + parentUuid);
+            NodeId parentId = readNodeId(in);
+            log.info("ParentUUID: " + parentId);
         } catch (IOException e) {
-            log.error("Error while reading ParentUUID: " + e);
+            log.error("Error while reading ParentId: " + e);
             return false;
         }
         try {
@@ -208,11 +207,11 @@
             return false;
         }
         try {
-            UUID cneUUID = readUUID(in);
-            while (cneUUID != null) {
+            NodeId cneId = readNodeId(in);
+            while (cneId != null) {
                 Name cneName = readQName(in);
-                log.info("ChildNodentry: " + cneUUID + ":" + cneName);
-                cneUUID = readUUID(in);
+                log.info("ChildNodentry: " + cneId + ":" + cneName);
+                cneId = readNodeId(in);
             }
         } catch (IOException e) {
             log.error("Error while reading child node entry: " + e);
@@ -363,7 +362,7 @@
                     val = InternalValue.create(readQName(in));
                     break;
                 case PropertyType.REFERENCE:
-                    val = InternalValue.create(readUUID(in));
+                    val = InternalValue.create(readNodeId(in));
                     break;
                 default:
                     // because writeUTF(String) has a size limit of 64k,
@@ -503,8 +502,8 @@
                     break;
                 case PropertyType.REFERENCE:
                     try {
-                        UUID uuid = readUUID(in);
-                        log.info("  reference: " + uuid);
+                        NodeId id = readNodeId(in);
+                        log.info("  reference: " + id);
                     } catch (IOException e) {
                         log.error("Error while reading reference value: " + e);
                         return false;
@@ -671,7 +670,7 @@
                     writeQName(out, val.getQName());
                     break;
                 case PropertyType.REFERENCE:
-                    writeUUID(out, val.getUUID());
+                    writeNodeId(out, val.getNodeId());
                     break;
                 default:
                     // because writeUTF(String) has a size limit of 64k,
Index: src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java	(working copy)
@@ -26,7 +26,6 @@
 import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.nodetype.NodeDefId;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.name.NameFactoryImpl;
 
 import java.io.DataInputStream;
@@ -263,14 +262,14 @@
      * @return the uuid
      * @throws IOException in an I/O error occurs.
      */
-    public UUID readUUID(DataInputStream in) throws IOException {
+    public NodeId readNodeId(DataInputStream in) throws IOException {
         if (in.readBoolean()) {
             byte[] bytes = new byte[16];
             int pos = 0;
             while (pos < 16) {
                 pos += in.read(bytes, pos, 16 - pos);
             }
-            return new UUID(bytes);
+            return new NodeId(bytes);
         } else {
             return null;
         }
@@ -282,12 +281,12 @@
      * @param uuid the uuid
      * @throws IOException in an I/O error occurs.
      */
-    public void writeUUID(DataOutputStream out, String uuid) throws IOException {
-        if (uuid == null) {
+    public void writeNodeId(DataOutputStream out, NodeId id) throws IOException {
+        if (id == null) {
             out.writeBoolean(false);
         } else {
             out.writeBoolean(true);
-            out.write(UUID.fromString(uuid).getRawBytes());
+            out.write(id.getRawBytes());
         }
     }
 
@@ -304,7 +303,7 @@
             while (pos < 16) {
                 pos += in.read(bytes, pos, 16 - pos);
             }
-            return new NodeId(new UUID(bytes));
+            return new NodeId(bytes);
         } else {
             return null;
         }
@@ -321,26 +320,11 @@
             out.writeBoolean(false);
         } else {
             out.writeBoolean(true);
-            out.write(id.getUUID().getRawBytes());
+            out.write(id.getRawBytes());
         }
     }
 
     /**
-     * Serializes a UUID
-     * @param out the output stream
-     * @param uuid the uuid
-     * @throws IOException in an I/O error occurs.
-     */
-    public void writeUUID(DataOutputStream out, UUID uuid) throws IOException {
-        if (uuid == null) {
-            out.writeBoolean(false);
-        } else {
-            out.writeBoolean(true);
-            out.write(uuid.getRawBytes());
-        }
-    }
-
-    /**
      * Deserializes a Name
      * @param in the input stream
      * @return the qname
@@ -433,8 +417,8 @@
      * @throws IOException in an I/O error occurs.
      */
     public PropertyId readPropertyId(DataInputStream in) throws IOException {
-        UUID uuid = readUUID(in);
+        NodeId id = readNodeId(in);
         Name name = readQName(in);
-        return new PropertyId(new NodeId(uuid), name);
+        return new PropertyId(id, name);
     }
 }
Index: src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java	(working copy)
@@ -159,7 +159,7 @@
         if (buf == null) {
             buf = new StringBuffer();
         }
-        char[] chars = id.getUUID().toString().toCharArray();
+        char[] chars = id.toString().toCharArray();
         int cnt = 0;
         for (int i = 0; i < chars.length; i++) {
             if (chars[i] == '-') {
@@ -449,7 +449,7 @@
                 state.setType(PropertyType.STRING);
                 state.setDefinitionId(idJcrUUID);
                 state.setMultiValued(false);
-                state.setValues(new InternalValue[]{InternalValue.create(id.getParentId().getUUID().toString())});
+                state.setValues(new InternalValue[]{InternalValue.create(id.getParentId().toString())});
             } else if (id.getName().equals(NameConstants.JCR_PRIMARYTYPE)) {
                 state = createNew(id);
                 state.setType(PropertyType.NAME);
Index: src/main/java/org/apache/jackrabbit/core/persistence/bundle/Oracle9PersistenceManager.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/persistence/bundle/Oracle9PersistenceManager.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/persistence/bundle/Oracle9PersistenceManager.java	(working copy)
@@ -120,7 +120,7 @@
 
             String sql = bundle.isNew() ? bundleInsertSQL : bundleUpdateSQL;
             blob = createTemporaryBlob(new ByteArrayInputStream(out.toByteArray()));
-            Object[] params = createParams(bundle.getId().getUUID(), blob, true);
+            Object[] params = createParams(bundle.getId(), blob, true);
             connectionManager.executeStmt(sql, params);
         } catch (Exception e) {
             String msg = "failed to write bundle: " + bundle.getId();
@@ -159,7 +159,7 @@
             // not have to additionally synchronize on the preparedStatement
 
             blob = createTemporaryBlob(new ByteArrayInputStream(out.toByteArray()));
-            Object[] params = createParams(refs.getTargetId().getUUID(), blob, true);
+            Object[] params = createParams(refs.getTargetId(), blob, true);
             connectionManager.executeStmt(sql, params);
 
             // there's no need to close a ByteArrayOutputStream
Index: src/main/java/org/apache/jackrabbit/core/persistence/obj/ObjectPersistenceManager.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/persistence/obj/ObjectPersistenceManager.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/persistence/obj/ObjectPersistenceManager.java	(working copy)
@@ -84,7 +84,7 @@
 
     private static String buildNodeFolderPath(NodeId id) {
         StringBuffer sb = new StringBuffer();
-        char[] chars = id.getUUID().toString().toCharArray();
+        char[] chars = id.toString().toCharArray();
         int cnt = 0;
         for (int i = 0; i < chars.length; i++) {
             if (chars[i] == '-') {
@@ -207,7 +207,7 @@
                 Serializer.deserialize(state, in);
                 return state;
             } catch (Exception e) {
-                String msg = "failed to read node state: " + id.getUUID();
+                String msg = "failed to read node state: " + id;
                 log.debug(msg);
                 throw new ItemStateException(msg, e);
             } finally {
Index: src/main/java/org/apache/jackrabbit/core/persistence/util/FileSystemBLOBStore.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/persistence/util/FileSystemBLOBStore.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/persistence/util/FileSystemBLOBStore.java	(working copy)
@@ -53,7 +53,7 @@
         // the blobId is an absolute file system path
         StringBuffer sb = new StringBuffer();
         sb.append(FileSystem.SEPARATOR_CHAR);
-        char[] chars = id.getParentId().getUUID().toString().toCharArray();
+        char[] chars = id.getParentId().toString().toCharArray();
         int cnt = 0;
         for (int i = 0; i < chars.length; i++) {
             if (chars[i] == '-') {
Index: src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java	(working copy)
@@ -79,7 +79,7 @@
         if (state.getParentId() == null) {
             out.write(NULL_UUID_PLACEHOLDER_BYTES);
         } else {
-            out.write(state.getParentId().getUUID().getRawBytes());
+            out.write(state.getParentId().getRawBytes());
         }
         // definitionId
         out.writeUTF(state.getDefinitionId().toString());
@@ -104,7 +104,7 @@
         for (Iterator iter = c.iterator(); iter.hasNext();) {
             NodeState.ChildNodeEntry entry = (NodeState.ChildNodeEntry) iter.next();
             out.writeUTF(entry.getName().toString());   // name
-            out.write(entry.getId().getUUID().getRawBytes());    // uuid
+            out.write(entry.getId().getRawBytes());    // uuid
         }
     }
 
@@ -128,7 +128,7 @@
         byte[] uuidBytes = new byte[UUID.UUID_BYTE_LENGTH];
         in.readFully(uuidBytes);
         if (!Arrays.equals(uuidBytes, NULL_UUID_PLACEHOLDER_BYTES)) {
-            state.setParentId(new NodeId(new UUID(uuidBytes)));
+            state.setParentId(new NodeId(uuidBytes));
         }
         // definitionId
         s = in.readUTF();
@@ -156,7 +156,7 @@
             Name name = NameFactoryImpl.getInstance().create(in.readUTF());    // name
             // uuid
             in.readFully(uuidBytes);
-            state.addChildNodeEntry(name, new NodeId(new UUID(uuidBytes)));
+            state.addChildNodeEntry(name, new NodeId(uuidBytes));
         }
     }
 
Index: src/main/java/org/apache/jackrabbit/core/SessionImpl.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/SessionImpl.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/SessionImpl.java	(working copy)
@@ -97,7 +97,6 @@
 import org.apache.jackrabbit.namespace.NamespaceResolver;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.value.ValueFactoryImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -445,35 +444,6 @@
     }
 
     /**
-     * Retrieves the referenceable node with the given <code>UUID</code>.
-     *
-     * @param uuid uuid of the node to be retrieved
-     * @return referenceable node with the given uuid
-     * @throws ItemNotFoundException if no node exists with the given uuid or
-     * if the existing node is not referenceable.
-     * @throws RepositoryException if another error occurs.
-     * @see #getNodeByUUID(String)
-     * @see #getNodeById(NodeId)
-     */
-    public Node getNodeByUUID(UUID uuid) throws ItemNotFoundException, RepositoryException {
-        NodeImpl node = getNodeById(new NodeId(uuid));
-        // since the uuid of a node is only exposed through jcr:uuid declared
-        // by mix:referenceable it's rather unlikely that a client can possibly
-        // know the internal uuid of a non-referenceable node; omitting the
-        // check for mix:referenceable seems therefore to be a reasonable
-        // compromise in order to improve performance.
-/*
-        if (node.isNodeType(Name.MIX_REFERENCEABLE)) {
-            return node;
-        } else {
-            // there is a node with that uuid but the node does not expose it
-            throw new ItemNotFoundException(uuid.toString());
-        }
-*/
-        return node;
-    }
-
-    /**
      * Retrieves the <code>Node</code> with the given id.
      *
      * @param id id of node to be retrieved
@@ -804,7 +774,21 @@
      */
     public Node getNodeByUUID(String uuid) throws ItemNotFoundException, RepositoryException {
         try {
-            return getNodeByUUID(UUID.fromString(uuid));
+            NodeImpl node = getNodeById(NodeId.valueOf(uuid));
+            // since the uuid of a node is only exposed through jcr:uuid declared
+            // by mix:referenceable it's rather unlikely that a client can possibly
+            // know the internal uuid of a non-referenceable node; omitting the
+            // check for mix:referenceable seems therefore to be a reasonable
+            // compromise in order to improve performance.
+            /*
+            if (node.isNodeType(Name.MIX_REFERENCEABLE)) {
+                return node;
+            } else {
+                // there is a node with that uuid but the node does not expose it
+                throw new ItemNotFoundException(uuid.toString());
+            }
+             */
+            return node;
         } catch (IllegalArgumentException e) {
             // Assuming the exception is from UUID.fromString()
             throw new RepositoryException("Invalid UUID: " + uuid, e);
Index: src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/PropertyImpl.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/PropertyImpl.java	(working copy)
@@ -23,7 +23,6 @@
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.value.BooleanValue;
 import org.apache.jackrabbit.value.DateValue;
 import org.apache.jackrabbit.value.DoubleValue;
@@ -634,8 +633,7 @@
         InternalValue val = state.getValues()[0];
         if (val.getType() == PropertyType.REFERENCE) {
             // reference, i.e. target UUID
-            UUID targetUUID = val.getUUID();
-            return (Node) itemMgr.getItem(new NodeId(targetUUID));
+            return (Node) itemMgr.getItem(val.getNodeId());
         } else {
             throw new ValueFormatException("property must be of type REFERENCE");
         }
@@ -895,7 +893,7 @@
             if (target instanceof NodeImpl) {
                 NodeImpl targetNode = (NodeImpl) target;
                 if (targetNode.isNodeType(NameConstants.MIX_REFERENCEABLE)) {
-                    InternalValue value = InternalValue.create(new UUID(targetNode.getUUID()));
+                    InternalValue value = InternalValue.create(targetNode.getNodeId());
                     internalSetValue(new InternalValue[]{value}, reqType);
                 } else {
                     throw new ValueFormatException("target node must be of node type mix:referenceable");
Index: src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java	(working copy)
@@ -34,7 +34,6 @@
 import org.apache.jackrabbit.core.state.ItemStateReferenceMap;
 import org.apache.jackrabbit.core.state.ItemStateListener;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.util.WeakIdentityCollection;
 import org.apache.jackrabbit.name.NameConstants;
 import org.slf4j.Logger;
@@ -286,7 +285,7 @@
         // create a new node state
         VirtualNodeState state;
         if (id == null) {
-            id = new NodeId(UUID.randomUUID());
+            id = NodeId.randomNodeId();
         }
         state = new VirtualNodeState(this, parent.getNodeId(), id, nodeTypeName, new Name[0]);
         state.setDefinitionId(def);
Index: src/main/java/org/apache/jackrabbit/core/NodeImpl.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/NodeImpl.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/NodeImpl.java	(working copy)
@@ -48,7 +48,6 @@
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.util.ChildrenCollectorFilter;
 import org.apache.jackrabbit.util.IteratorHelper;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.value.ValueHelper;
 import org.apache.jackrabbit.name.NameConstants;
 import org.apache.jackrabbit.name.PathFactoryImpl;
@@ -321,7 +320,7 @@
             if (name.equals(NameConstants.JCR_UUID)) {
                 // jcr:uuid property
                 genValues = new InternalValue[]{
-                        InternalValue.create(thisState.getNodeId().getUUID().toString())
+                        InternalValue.create(thisState.getNodeId().toString())
                 };
             }
 /*
@@ -527,7 +526,7 @@
         NodeState nodeState;
         try {
             if (id == null) {
-                id = new NodeId(UUID.randomUUID());
+                id = NodeId.randomNodeId();
             }
             nodeState =
                     stateMgr.createTransientNodeState(id, nodeType.getQName(),
@@ -1269,15 +1268,6 @@
     }
 
     /**
-     * Returns the (internal) uuid of this node.
-     *
-     * @return the uuid of this node
-     */
-    public UUID internalGetUUID() {
-        return ((NodeId) id).getUUID();
-    }
-
-    /**
      * Checks various pre-conditions that are common to all
      * <code>setProperty()</code> methods. The checks performed are:
      * <ul>
@@ -1543,8 +1533,8 @@
      * @param nodeName     name of the new node
      * @param nodeTypeName name of the new node's node type or <code>null</code>
      *                     if it should be determined automatically
-     * @param uuid         uuid of the new node or <code>null</code> if a new
-     *                     uuid should be assigned
+     * @param id           id of the new node or <code>null</code> if a new
+     *                     id should be assigned
      * @return the newly added node
      * @throws ItemExistsException
      * @throws NoSuchNodeTypeException
@@ -1553,8 +1543,8 @@
      * @throws LockException
      * @throws RepositoryException
      */
-    public synchronized NodeImpl addNode(Name nodeName, Name nodeTypeName,
-                                         UUID uuid)
+    public synchronized NodeImpl addNode(
+            Name nodeName, Name nodeTypeName, NodeId id)
             throws ItemExistsException, NoSuchNodeTypeException, VersionException,
             ConstraintViolationException, LockException, RepositoryException {
         // check state of this instance
@@ -1574,7 +1564,7 @@
         if (nodeTypeName != null) {
             nt = session.getNodeTypeManager().getNodeType(nodeTypeName);
         }
-        return internalAddChildNode(nodeName, nt, uuid == null ? null : new NodeId(uuid));
+        return internalAddChildNode(nodeName, nt, id);
     }
 
     /**
@@ -1910,7 +1900,7 @@
         existing.remove();
 
         // create new child node
-        NodeImpl node = addNode(nodeName, nodeTypeName, id.getUUID());
+        NodeImpl node = addNode(nodeName, nodeTypeName, id);
         if (mixinNames != null) {
             for (int i = 0; i < mixinNames.length; i++) {
                 node.addMixin(mixinNames[i]);
@@ -2866,7 +2856,7 @@
             throw new UnsupportedRepositoryOperationException();
         }
 
-        return internalGetUUID().toString();
+        return id.toString();
     }
 
     /**
@@ -2992,7 +2982,7 @@
 
         Version v = session.getVersionManager().checkin(this);
         internalSetProperty(NameConstants.JCR_ISCHECKEDOUT, InternalValue.create(false));
-        internalSetProperty(NameConstants.JCR_BASEVERSION, InternalValue.create(new UUID(v.getUUID())));
+        internalSetProperty(NameConstants.JCR_BASEVERSION, InternalValue.create(NodeId.valueOf(v.getUUID())));
         internalSetProperty(NameConstants.JCR_PREDECESSORS, InternalValue.EMPTY_ARRAY, PropertyType.REFERENCE);
         save();
         return v;
@@ -3024,7 +3014,7 @@
         prop.save();
         prop = internalSetProperty(NameConstants.JCR_PREDECESSORS,
                 new InternalValue[]{
-                    InternalValue.create(new UUID(getBaseVersion().getUUID()))
+                    InternalValue.create(NodeId.valueOf(getBaseVersion().getUUID()))
                 });
         prop.save();
     }
@@ -3140,7 +3130,7 @@
             try {
                 // check if versionable node exists
                 InternalFrozenNode fn = ((VersionImpl) version).getFrozenNode();
-                node = (NodeImpl) session.getNodeByUUID(fn.getFrozenUUID());
+                node = (NodeImpl) session.getNodeById(fn.getFrozenId());
                 if (removeExisting) {
                     try {
                         Path relative = session.getQPath(relPath);
@@ -3150,7 +3140,7 @@
                         // move to respective location
                         session.move(node.getPath(), session.getJCRPath(dstPath));
                         // need to refetch ?
-                        node = (NodeImpl) session.getNodeByUUID(fn.getFrozenUUID());
+                        node = (NodeImpl) session.getNodeById(fn.getFrozenId());
                     } catch (NameException e) {
                         throw new RepositoryException(e);
                     }
@@ -3200,7 +3190,8 @@
         checkVersionable();
 
         // transactions workaround.
-        NodeId id = NodeId.valueOf(getProperty(NameConstants.JCR_VERSIONHISTORY).getString());
+        NodeId id = NodeId.valueOf(
+                getProperty(NameConstants.JCR_VERSIONHISTORY).getString());
         session.getVersionManager().getVersionHistory(id);
 
         return (VersionHistory) getProperty(NameConstants.JCR_VERSIONHISTORY).getNode();
@@ -3217,7 +3208,8 @@
         checkVersionable();
 
         // transactions workaround.
-        NodeId id = NodeId.valueOf(getProperty(NameConstants.JCR_BASEVERSION).getString());
+        NodeId id = NodeId.valueOf(
+                getProperty(NameConstants.JCR_BASEVERSION).getString());
         session.getVersionManager().getVersion(id);
 
         return (Version) getProperty(NameConstants.JCR_BASEVERSION).getNode();
@@ -3466,9 +3458,9 @@
             Value[] vals = getProperty(NameConstants.JCR_PREDECESSORS).getValues();
             InternalValue[] v = new InternalValue[vals.length + 1];
             for (int i = 0; i < vals.length; i++) {
-                v[i] = InternalValue.create(UUID.fromString(vals[i].getString()));
+                v[i] = InternalValue.create(NodeId.valueOf(vals[i].getString()));
             }
-            v[vals.length] = InternalValue.create(UUID.fromString(version.getUUID()));
+            v[vals.length] = InternalValue.create(NodeId.valueOf(version.getUUID()));
             internalSetProperty(NameConstants.JCR_PREDECESSORS, v);
         }
 
@@ -3504,7 +3496,7 @@
             int i = 0;
             while (iter.hasNext()) {
                 String uuid = (String) iter.next();
-                vals[i++] = InternalValue.create(UUID.fromString(uuid));
+                vals[i++] = InternalValue.create(NodeId.valueOf(uuid));
             }
             internalSetProperty(NameConstants.JCR_MERGEFAILED, vals);
         }
@@ -3578,11 +3570,8 @@
         NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
         NodeTypeImpl nt = ntMgr.getNodeType(frozen.getFrozenPrimaryType());
 
-        // get frozen uuid
-        UUID uuid = frozen.getFrozenUUID();
+        NodeImpl node = internalAddChildNode(name, nt, frozen.getFrozenId());
 
-        NodeImpl node = internalAddChildNode(name, nt, new NodeId(uuid));
-
         // get frozen mixin
         // todo: also respect mixing types on creation?
         Name[] mxNames = frozen.getFrozenMixinTypes();
@@ -3622,11 +3611,8 @@
         NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
         NodeTypeImpl nt = ntMgr.getNodeType(frozen.getFrozenPrimaryType());
 
-        // get frozen uuid
-        UUID uuid = frozen.getFrozenUUID();
+        NodeImpl node = internalAddNode(relPath, nt, frozen.getFrozenId());
 
-        NodeImpl node = internalAddNode(relPath, nt, new NodeId(uuid));
-
         // get frozen mixin
         // todo: also respect mixing types on creation?
         Name[] mxNames = frozen.getFrozenMixinTypes();
@@ -3861,8 +3847,8 @@
         restored.add(version);
 
         // 2. N's jcr:baseVersion property will be changed to point to V.
-        UUID uuid = ((NodeId) version.getId()).getUUID();
-        internalSetProperty(NameConstants.JCR_BASEVERSION, InternalValue.create(uuid));
+        NodeId id = (NodeId) version.getId();
+        internalSetProperty(NameConstants.JCR_BASEVERSION, InternalValue.create(id));
 
         // 4. N's jcr:predecessor property is set to null
         internalSetProperty(NameConstants.JCR_PREDECESSORS, InternalValue.EMPTY_ARRAY, PropertyType.REFERENCE);
@@ -3889,8 +3875,7 @@
 
         // check uuid
         if (isNodeType(NameConstants.MIX_REFERENCEABLE)) {
-            UUID uuid = freeze.getFrozenUUID();
-            if (!internalGetUUID().equals(uuid)) {
+            if (!id.equals(freeze.getFrozenId())) {
                 throw new ItemExistsException("Unable to restore version of " + safeGetJCRPath() + ". UUID changed.");
             }
         }
@@ -3958,11 +3943,12 @@
             } else if (n.getDefinition().getOnParentVersion() == OnParentVersionAction.VERSION) {
                 // only remove, if node to be restored does not contain child,
                 // or if restored child is not versionable
-                UUID vhUUID = n.hasProperty(NameConstants.JCR_VERSIONHISTORY)
-                        ? new UUID(n.getProperty(NameConstants.JCR_VERSIONHISTORY).getString())
-                        : null;
-                if (vhUUID == null || !freeze.hasFrozenHistory(vhUUID)) {
-                    n.internalRemove(true);
+                if (n.hasProperty(NameConstants.JCR_VERSIONHISTORY)) {
+                    NodeId vhId = NodeId.valueOf(n.getProperty(
+                            NameConstants.JCR_VERSIONHISTORY).getString());
+                    if (!freeze.hasFrozenHistory(vhId)) {
+                        n.internalRemove(true);
+                    }
                 }
             }
         }
@@ -3975,9 +3961,9 @@
             if (child instanceof InternalFrozenNode) {
                 InternalFrozenNode f = (InternalFrozenNode) child;
                 // check for existing
-                if (f.getFrozenUUID() != null) {
+                if (f.getFrozenId() != null) {
                     try {
-                        NodeImpl existing = (NodeImpl) session.getNodeByUUID(f.getFrozenUUID());
+                        NodeImpl existing = (NodeImpl) session.getNodeById(f.getFrozenId());
                         // check if one of this restoretrees node
                         if (removeExisting) {
                             existing.remove();
Index: src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java	(working copy)
@@ -38,7 +38,6 @@
 import org.apache.jackrabbit.conversion.MalformedPathException;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.name.NameConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -332,8 +331,8 @@
             InternalValue[] newVals = new InternalValue[values.length];
             for (int i = 0; i < values.length; i++) {
                 InternalValue val = values[i];
-                UUID original = val.getUUID();
-                UUID adjusted = refTracker.getMappedUUID(original);
+                NodeId original = val.getNodeId();
+                NodeId adjusted = refTracker.getMappedId(original);
                 if (adjusted != null) {
                     newVals[i] = InternalValue.create(adjusted);
                     modified = true;
@@ -1015,7 +1014,7 @@
         }
         if (id == null) {
             // create new id
-            id = new NodeId(UUID.randomUUID());
+            id = NodeId.randomNodeId();
         }
         if (nodeTypeName == null) {
             // no primary node type specified,
@@ -1436,7 +1435,7 @@
             if (NameConstants.JCR_UUID.equals(name)) {
                 // jcr:uuid property
                 genValues = new InternalValue[]{InternalValue.create(
-                        parent.getNodeId().getUUID().toString())};
+                        parent.getNodeId().toString())};
             }
         } else if (NameConstants.NT_BASE.equals(declaringNT)) {
             // nt:base node type
@@ -1589,16 +1588,16 @@
             switch (flag) {
                 case COPY:
                     // always create new uuid
-                    id = new NodeId(UUID.randomUUID());
+                    id = NodeId.randomNodeId();
                     if (referenceable) {
                         // remember uuid mapping
-                        refTracker.mappedUUID(srcState.getNodeId().getUUID(), id.getUUID());
+                        refTracker.mappedId(srcState.getNodeId(), id);
                     }
                     break;
                 case CLONE:
                     if (!referenceable) {
-                        // non-referenceable node: always create new uuid
-                        id = new NodeId(UUID.randomUUID());
+                        // non-referenceable node: always create new id
+                        id = NodeId.randomNodeId();
                         break;
                     }
                     // use same uuid as source node
@@ -1610,8 +1609,8 @@
                     break;
                 case CLONE_REMOVE_EXISTING:
                     if (!referenceable) {
-                        // non-referenceable node: always create new uuid
-                        id = new NodeId(UUID.randomUUID());
+                        // non-referenceable node: always create new id
+                        id = NodeId.randomNodeId();
                         break;
                     }
                     // use same uuid as source node
@@ -1708,15 +1707,15 @@
                     if (propName.equals(NameConstants.JCR_VERSIONHISTORY)) {
                         // jcr:versionHistory
                         VersionHistory vh = getOrCreateVersionHistory(newState);
-                        newChildState.setValues(new InternalValue[]{InternalValue.create(new UUID(vh.getUUID()))});
+                        newChildState.setValues(new InternalValue[]{InternalValue.create(NodeId.valueOf(vh.getUUID()))});
                     } else if (propName.equals(NameConstants.JCR_BASEVERSION)) {
                         // jcr:baseVersion
                         VersionHistory vh = getOrCreateVersionHistory(newState);
-                        newChildState.setValues(new InternalValue[]{InternalValue.create(new UUID(vh.getRootVersion().getUUID()))});
+                        newChildState.setValues(new InternalValue[]{InternalValue.create(NodeId.valueOf(vh.getRootVersion().getUUID()))});
                     } else if (propName.equals(NameConstants.JCR_PREDECESSORS)) {
                         // jcr:predecessors
                         VersionHistory vh = getOrCreateVersionHistory(newState);
-                        newChildState.setValues(new InternalValue[]{InternalValue.create(new UUID(vh.getRootVersion().getUUID()))});
+                        newChildState.setValues(new InternalValue[]{InternalValue.create(NodeId.valueOf(vh.getRootVersion().getUUID()))});
                     } else if (propName.equals(NameConstants.JCR_ISCHECKEDOUT)) {
                         // jcr:isCheckedOut
                         newChildState.setValues(new InternalValue[]{InternalValue.create(true)});
@@ -1773,7 +1772,7 @@
             if (def.getDeclaringNodeType().equals(NameConstants.MIX_REFERENCEABLE)
                     && propName.equals(NameConstants.JCR_UUID)) {
                 // set correct value of jcr:uuid property
-                newState.setValues(new InternalValue[]{InternalValue.create(parentId.getUUID().toString())});
+                newState.setValues(new InternalValue[]{InternalValue.create(parentId.toString())});
             } else {
                 InternalValue[] newValues = new InternalValue[values.length];
                 for (int i = 0; i < values.length; i++) {
Index: src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java	(working copy)
@@ -20,7 +20,6 @@
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.document.Document;
 import org.slf4j.Logger;
@@ -64,9 +63,9 @@
     private final MultiIndex index;
 
     /**
-     * All the document UUIDs within the index.
+     * All the document ids within the index.
      */
-    private Set documentUUIDs;
+    private Set documentIds;
 
     /**
      * List of all errors.
@@ -150,8 +149,8 @@
     private void run() throws IOException {
         // UUIDs of multiple nodes in the index
         Set multipleEntries = new HashSet();
-        // collect all documents UUIDs
-        documentUUIDs = new HashSet();
+        // collect all documents ids
+        documentIds = new HashSet();
         IndexReader reader = index.getIndexReader();
         try {
             for (int i = 0; i < reader.maxDoc(); i++) {
@@ -163,13 +162,13 @@
                     continue;
                 }
                 Document d = reader.document(i);
-                UUID uuid = UUID.fromString(d.get(FieldNames.UUID));
-                if (stateMgr.hasItemState(new NodeId(uuid))) {
-                    if (!documentUUIDs.add(uuid)) {
-                        multipleEntries.add(uuid);
+                NodeId id = NodeId.valueOf(d.get(FieldNames.UUID));
+                if (stateMgr.hasItemState(id)) {
+                    if (!documentIds.add(id)) {
+                        multipleEntries.add(id);
                     }
                 } else {
-                    errors.add(new NodeDeleted(uuid));
+                    errors.add(new NodeDeleted(id));
                 }
             }
         } finally {
@@ -178,7 +177,7 @@
 
         // create multiple entries errors
         for (Iterator it = multipleEntries.iterator(); it.hasNext();) {
-            errors.add(new MultipleEntries((UUID) it.next()));
+            errors.add(new MultipleEntries((NodeId) it.next()));
         }
 
         reader = index.getIndexReader();
@@ -193,21 +192,20 @@
                     continue;
                 }
                 Document d = reader.document(i);
-                UUID uuid = UUID.fromString(d.get(FieldNames.UUID));
-                String parentUUIDString = d.get(FieldNames.PARENT);
-                UUID parentUUID = null;
-                if (parentUUIDString.length() > 0) {
-                    parentUUID = UUID.fromString(parentUUIDString);
+                NodeId id = NodeId.valueOf(d.get(FieldNames.UUID));
+                String parentIdString = d.get(FieldNames.PARENT);
+                NodeId parentId = null;
+                if (parentIdString.length() > 0) {
+                    parentId = NodeId.valueOf(parentIdString);
                 }
-                if (parentUUID == null || documentUUIDs.contains(parentUUID)) {
+                if (parentId == null || documentIds.contains(parentId)) {
                     continue;
                 }
                 // parent is missing
-                NodeId parentId = new NodeId(parentUUID);
                 if (stateMgr.hasItemState(parentId)) {
-                    errors.add(new MissingAncestor(uuid, parentUUID));
+                    errors.add(new MissingAncestor(id, parentId));
                 } else {
-                    errors.add(new UnknownParent(uuid, parentUUID));
+                    errors.add(new UnknownParent(id, parentId));
                 }
             }
         } finally {
@@ -258,11 +256,11 @@
      */
     private class MissingAncestor extends ConsistencyCheckError {
 
-        private final UUID parentUUID;
+        private final NodeId parentId;
 
-        private MissingAncestor(UUID uuid, UUID parentUUID) {
-            super("Parent of " + uuid + " missing in index. Parent: " + parentUUID, uuid);
-            this.parentUUID = parentUUID;
+        private MissingAncestor(NodeId id, NodeId parentId) {
+            super("Parent of " + id + " missing in index. Parent: " + parentId, id);
+            this.parentId = parentId;
         }
 
         /**
@@ -278,15 +276,15 @@
          * @throws IOException if an error occurs while repairing.
          */
         public void repair() throws IOException {
-            NodeId parentId = new NodeId(parentUUID);
-            while (parentId != null && !documentUUIDs.contains(parentId.getUUID())) {
+            NodeId id = parentId;
+            while (id != null && !documentIds.contains(id)) {
                 try {
-                    NodeState n = (NodeState) stateMgr.getItemState(parentId);
+                    NodeState n = (NodeState) stateMgr.getItemState(id);
                     log.info("Reparing missing node " + getPath(n));
                     Document d = index.createDocument(n);
                     index.addDocument(d);
-                    documentUUIDs.add(n.getNodeId().getUUID());
-                    parentId = n.getParentId();
+                    documentIds.add(n.getNodeId());
+                    id = n.getParentId();
                 } catch (ItemStateException e) {
                     throw new IOException(e.toString());
                 } catch (RepositoryException e) {
@@ -301,8 +299,8 @@
      */
     private class UnknownParent extends ConsistencyCheckError {
 
-        private UnknownParent(UUID uuid, UUID parentUUID) {
-            super("Node " + uuid + " has unknown parent: " + parentUUID, uuid);
+        private UnknownParent(NodeId id, NodeId parentId) {
+            super("Node " + id + " has unknown parent: " + parentId, id);
         }
 
         /**
@@ -317,7 +315,7 @@
          * No operation.
          */
         public void repair() throws IOException {
-            log.warn("Unknown parent for " + uuid + " cannot be repaired");
+            log.warn("Unknown parent for " + id + " cannot be repaired");
         }
     }
 
@@ -326,8 +324,8 @@
      */
     private class MultipleEntries extends ConsistencyCheckError {
 
-        MultipleEntries(UUID uuid) {
-            super("Multiple entries found for node " + uuid, uuid);
+        MultipleEntries(NodeId id) {
+            super("Multiple entries found for node " + id, id);
         }
 
         /**
@@ -345,14 +343,14 @@
          */
         public void repair() throws IOException {
             // first remove all occurrences
-            index.removeAllDocuments(uuid);
+            index.removeAllDocuments(id);
             // then re-index the node
             try {
-                NodeState node = (NodeState) stateMgr.getItemState(new NodeId(uuid));
+                NodeState node = (NodeState) stateMgr.getItemState(id);
                 log.info("Re-indexing duplicate node occurrences in index: " + getPath(node));
                 Document d = index.createDocument(node);
                 index.addDocument(d);
-                documentUUIDs.add(node.getNodeId().getUUID());
+                documentIds.add(node.getNodeId());
             } catch (ItemStateException e) {
                 throw new IOException(e.toString());
             } catch (RepositoryException e) {
@@ -366,8 +364,8 @@
      */
     private class NodeDeleted extends ConsistencyCheckError {
 
-        NodeDeleted(UUID uuid) {
-            super("Node " + uuid + " does not longer exist.", uuid);
+        NodeDeleted(NodeId id) {
+            super("Node " + id + " does not longer exist.", id);
         }
 
         /**
@@ -383,8 +381,8 @@
          * @throws IOException if an error occurs while repairing.
          */
         public void repair() throws IOException {
-            log.info("Removing deleted node from index: " + uuid);
-            index.removeDocument(uuid);
+            log.info("Removing deleted node from index: " + id);
+            index.removeDocument(id);
         }
     }
 }
Index: src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingQueue.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingQueue.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingQueue.java	(working copy)
@@ -24,7 +24,6 @@
 import java.util.ArrayList;
 
 import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.lucene.document.Document;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -59,22 +58,21 @@
      */
     IndexingQueue(IndexingQueueStore queueStore, MultiIndex index) {
         this.queueStore = queueStore;
-        String[] uuids = queueStore.getPending();
-        for (int i = 0; i < uuids.length; i++) {
+        String[] ids = queueStore.getPending();
+        for (int i = 0; i < ids.length; i++) {
             try {
-                UUID uuid = UUID.fromString(uuids[i]);
-                Document doc = index.createDocument(new NodeId(uuid));
-                pendingDocuments.put(uuids[i], doc);
+                Document doc = index.createDocument(NodeId.valueOf(ids[i]));
+                pendingDocuments.put(ids[i], doc);
             } catch (IllegalArgumentException e) {
-                log.warn("Invalid UUID in indexing queue store: " + uuids[i]);
+                log.warn("Invalid id in indexing queue store: " + ids[i]);
             } catch (RepositoryException e) {
                 // node does not exist anymore
-                log.debug("Node with uuid {} does not exist anymore", uuids[i]);
+                log.debug("Node with id {} does not exist anymore", ids[i]);
                 try {
-                    queueStore.removeUUID(uuids[i]);
+                    queueStore.removeUUID(ids[i]);
                 } catch (IOException ex) {
                     log.warn("Unable to remove node {} from indexing queue",
-                            uuids[i], ex);
+                            ids[i], ex);
                 }
             }
         }
Index: src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java	(working copy)
@@ -24,7 +24,6 @@
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.uuid.Constants;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.util.Timer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -395,7 +394,7 @@
      * Atomically updates the index by removing some documents and adding
      * others.
      *
-     * @param remove Iterator of <code>UUID</code>s that identify documents to
+     * @param remove Iterator of ids that identify documents to
      *               remove
      * @param add    Iterator of <code>Document</code>s to add. Calls to
      *               <code>next()</code> on this iterator may return
@@ -412,7 +411,7 @@
 
             boolean flush = false;
             while (remove.hasNext()) {
-                executeAndLog(new DeleteNode(transactionId, (UUID) remove.next()));
+                executeAndLog(new DeleteNode(transactionId, (NodeId) remove.next()));
             }
             while (add.hasNext()) {
                 Document doc = (Document) add.next();
@@ -458,29 +457,29 @@
      * @param uuid document that match this <code>uuid</code> will be deleted.
      * @throws IOException if an error occurs while deleting the document.
      */
-    void removeDocument(UUID uuid) throws IOException {
-        List remove = Arrays.asList(new UUID[]{uuid});
+    void removeDocument(NodeId id) throws IOException {
+        List remove = Arrays.asList(new NodeId[]{ id });
         update(remove.iterator(), EmptyIterator.INSTANCE);
     }
 
     /**
-     * Deletes all documents that match the <code>uuid</code>.
+     * Deletes all documents that match the <code>id</code>.
      *
-     * @param uuid documents that match this <code>uuid</code> will be deleted.
+     * @param id documents that match this <code>id</code> will be deleted.
      * @return the number of deleted documents.
      * @throws IOException if an error occurs while deleting documents.
      */
-    synchronized int removeAllDocuments(UUID uuid) throws IOException {
+    synchronized int removeAllDocuments(NodeId id) throws IOException {
         synchronized (updateMonitor) {
             updateInProgress = true;
         }
         int num;
         try {
-            Term idTerm = new Term(FieldNames.UUID, uuid.toString());
+            Term idTerm = new Term(FieldNames.UUID, id.toString());
             executeAndLog(new Start(Action.INTERNAL_TRANSACTION));
             num = volatileIndex.removeDocument(idTerm);
             if (num > 0) {
-                redoLog.append(new DeleteNode(getTransactionId(), uuid));
+                redoLog.append(new DeleteNode(getTransactionId(), id));
             }
             for (int i = 0; i < indexes.size(); i++) {
                 PersistentIndex index = (PersistentIndex) indexes.get(i);
@@ -488,7 +487,7 @@
                 if (indexNames.contains(index.getName())) {
                     int removed = index.removeDocument(idTerm);
                     if (removed > 0) {
-                        redoLog.append(new DeleteNode(getTransactionId(), uuid));
+                        redoLog.append(new DeleteNode(getTransactionId(), id));
                     }
                     num += removed;
                 }
@@ -1014,7 +1013,7 @@
         if (excludedIDs.contains(id)) {
             return;
         }
-        executeAndLog(new AddNode(getTransactionId(), id.getUUID()));
+        executeAndLog(new AddNode(getTransactionId(), id));
         checkVolatileCommit();
         List children = node.getChildNodeEntries();
         for (Iterator it = children.iterator(); it.hasNext();) {
@@ -1133,8 +1132,8 @@
         Document[] docs = indexingQueue.getFinishedDocuments();
         Map finished = new HashMap();
         for (int i = 0; i < docs.length; i++) {
-            String uuid = docs[i].get(FieldNames.UUID);
-            finished.put(UUID.fromString(uuid), docs[i]);
+            String id = docs[i].get(FieldNames.UUID);
+            finished.put(NodeId.valueOf(id), docs[i]);
         }
 
         // now update index with the remaining ones if there are any
@@ -1457,9 +1456,9 @@
                 + 2;
 
         /**
-         * The uuid of the node to add.
+         * The id of the node to add.
          */
-        private final UUID uuid;
+        private final NodeId id;
 
         /**
          * The document to add to the index, or <code>null</code> if not available.
@@ -1470,11 +1469,11 @@
          * Creates a new AddNode action.
          *
          * @param transactionId the id of the transaction that executes this action.
-         * @param uuid the uuid of the node to add.
+         * @param id the id of the node to add.
          */
-        AddNode(long transactionId, UUID uuid) {
+        AddNode(long transactionId, NodeId id) {
             super(transactionId, Action.TYPE_ADD_NODE);
-            this.uuid = uuid;
+            this.id = id;
         }
 
         /**
@@ -1484,7 +1483,7 @@
          * @param doc the document to add.
          */
         AddNode(long transactionId, Document doc) {
-            this(transactionId, UUID.fromString(doc.get(FieldNames.UUID)));
+            this(transactionId, NodeId.valueOf(doc.get(FieldNames.UUID)));
             this.doc = doc;
         }
 
@@ -1505,7 +1504,7 @@
             if (arguments.length() != Constants.UUID_FORMATTED_LENGTH) {
                 throw new IllegalArgumentException("arguments is not a uuid");
             }
-            return new AddNode(transactionId, UUID.fromString(arguments));
+            return new AddNode(transactionId, NodeId.valueOf(arguments));
         }
 
         /**
@@ -1516,7 +1515,7 @@
         public void execute(MultiIndex index) throws IOException {
             if (doc == null) {
                 try {
-                    doc = index.createDocument(new NodeId(uuid));
+                    doc = index.createDocument(id);
                 } catch (RepositoryException e) {
                     // node does not exist anymore
                     log.debug(e.getMessage());
@@ -1536,7 +1535,7 @@
             logLine.append(' ');
             logLine.append(Action.ADD_NODE);
             logLine.append(' ');
-            logLine.append(uuid);
+            logLine.append(id);
             return logLine.toString();
         }
     }
@@ -1747,9 +1746,9 @@
                 + 2;
 
         /**
-         * The uuid of the node to remove.
+         * The id of the node to remove.
          */
-        private final UUID uuid;
+        private final NodeId id;
 
         /**
          * Creates a new DeleteNode action.
@@ -1757,9 +1756,9 @@
          * @param transactionId the id of the transaction that executes this action.
          * @param uuid the uuid of the node to delete.
          */
-        DeleteNode(long transactionId, UUID uuid) {
+        DeleteNode(long transactionId, NodeId id) {
             super(transactionId, Action.TYPE_DELETE_NODE);
-            this.uuid = uuid;
+            this.id = id;
         }
 
         /**
@@ -1777,7 +1776,7 @@
             if (arguments.length() != Constants.UUID_FORMATTED_LENGTH) {
                 throw new IllegalArgumentException("arguments is not a uuid");
             }
-            return new DeleteNode(transactionId, UUID.fromString(arguments));
+            return new DeleteNode(transactionId, NodeId.valueOf(arguments));
         }
 
         /**
@@ -1786,14 +1785,14 @@
          * @inheritDoc
          */
         public void execute(MultiIndex index) throws IOException {
-            String uuidString = uuid.toString();
+            String idString = id.toString();
             // check if indexing queue is still working on
             // this node from a previous update
-            Document doc = index.indexingQueue.removeDocument(uuidString);
+            Document doc = index.indexingQueue.removeDocument(idString);
             if (doc != null) {
                 Util.disposeDocument(doc);
             }
-            Term idTerm = new Term(FieldNames.UUID, uuidString);
+            Term idTerm = new Term(FieldNames.UUID, idString);
             // if the document cannot be deleted from the volatile index
             // delete it from one of the persistent indexes.
             int num = index.volatileIndex.removeDocument(idTerm);
@@ -1820,7 +1819,7 @@
             logLine.append(' ');
             logLine.append(Action.DELETE_NODE);
             logLine.append(' ');
-            logLine.append(uuid);
+            logLine.append(id);
             return logLine.toString();
         }
     }
Index: src/main/java/org/apache/jackrabbit/core/query/lucene/DocId.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/query/lucene/DocId.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/query/lucene/DocId.java	(working copy)
@@ -19,7 +19,7 @@
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermDocs;
-import org.apache.jackrabbit.uuid.UUID;
+import org.apache.jackrabbit.core.NodeId;
 
 import java.io.IOException;
 import java.util.BitSet;
@@ -27,7 +27,7 @@
 import java.lang.ref.WeakReference;
 
 /**
- * Implements a document id which can be based on a Node uuid or a lucene
+ * Implements a document id which can be based on a Node id or a lucene
  * document number.
  */
 abstract class DocId {
@@ -108,13 +108,13 @@
     }
 
     /**
-     * Creates a <code>DocId</code> based on a node UUID.
+     * Creates a <code>DocId</code> based on a node id.
      *
-     * @param uuid the node uuid.
-     * @return a <code>DocId</code> based on a node UUID.
+     * @param id the node id.
+     * @return a <code>DocId</code> based on a node id.
      */
-    static DocId create(String uuid) {
-        return new UUIDDocId(uuid);
+    static DocId create(String id) {
+        return new NodeIdDocId(id);
     }
 
     //--------------------------< internal >------------------------------------
@@ -172,7 +172,7 @@
     /**
      * <code>DocId</code> based on a UUID.
      */
-    private static final class UUIDDocId extends DocId {
+    private static final class NodeIdDocId extends DocId {
 
         /**
          * The least significant 64 bits of the uuid (bytes 8-15)
@@ -197,14 +197,14 @@
         private int docNumber;
 
         /**
-         * Creates a <code>DocId</code> based on a Node uuid.
+         * Creates a <code>DocId</code> based on a Node id.
          *
-         * @param uuid the Node uuid.
-         * @throws IllegalArgumentException if the <code>uuid</code> is
+         * @param id the Node id.
+         * @throws IllegalArgumentException if the <code>id</code> is
          *                                  malformed.
          */
-        UUIDDocId(String uuid) {
-            UUID tmp = UUID.fromString(uuid);
+        NodeIdDocId(String id) {
+            NodeId tmp = NodeId.valueOf(id);
             this.lsb = tmp.getLeastSignificantBits();
             this.msb = tmp.getMostSignificantBits();
         }
@@ -218,7 +218,7 @@
                     return docNumber;
                 }
             }
-            Term id = new Term(FieldNames.UUID, new UUID(msb, lsb).toString());
+            Term id = new Term(FieldNames.UUID, new NodeId(msb, lsb).toString());
             TermDocs docs = reader.termDocs(id);
             int doc = -1;
             try {
@@ -261,7 +261,7 @@
          * @return a String representation for this <code>DocId</code>.
          */
         public String toString() {
-            return "UUIDDocId(" + new UUID(msb, lsb) + ")";
+            return "UUIDDocId(" + new NodeId(msb, lsb) + ")";
         }
     }
 }
Index: src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractExcerpt.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractExcerpt.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractExcerpt.java	(working copy)
@@ -83,7 +83,7 @@
         IndexReader reader = index.getIndexReader();
         try {
             checkRewritten(reader);
-            Term idTerm = new Term(FieldNames.UUID, id.getUUID().toString());
+            Term idTerm = new Term(FieldNames.UUID, id.toString());
             TermDocs tDocs = reader.termDocs(idTerm);
             int docNumber;
             Document doc;
Index: src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java	(working copy)
@@ -30,7 +30,6 @@
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.name.NameConstants;
-import org.apache.jackrabbit.uuid.UUID;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.lucene.document.Document;
@@ -173,7 +172,7 @@
 
         // special fields
         // UUID
-        doc.add(new Field(FieldNames.UUID, node.getNodeId().getUUID().toString(), Field.Store.YES, Field.Index.NO_NORMS, Field.TermVector.NO));
+        doc.add(new Field(FieldNames.UUID, node.getNodeId().toString(), Field.Store.YES, Field.Index.NO_NORMS, Field.TermVector.NO));
         try {
             // parent UUID
             if (node.getParentId() == null) {
@@ -304,7 +303,7 @@
                 break;
             case PropertyType.REFERENCE:
                 if (isIndexed(name)) {
-                    addReferenceValue(doc, fieldName, value.getUUID());
+                    addReferenceValue(doc, fieldName, value);
                 }
                 break;
             case PropertyType.PATH:
@@ -510,10 +509,9 @@
      * @param fieldName     The name of the field to add
      * @param internalValue The value for the field to add to the document.
      */
-    protected void addReferenceValue(Document doc, String fieldName, Object internalValue) {
-        UUID value = (UUID) internalValue;
-        String uuid = value.toString();
-        doc.add(createFieldWithoutNorms(fieldName, uuid, true));
+    protected void addReferenceValue(Document doc, String fieldName, InternalValue internalValue) {
+        NodeId id = internalValue.getNodeId();
+        doc.add(createFieldWithoutNorms(fieldName, id.toString(), true));
     }
 
     /**
Index: src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java	(working copy)
@@ -35,7 +35,6 @@
 import org.apache.jackrabbit.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.name.NameConstants;
-import org.apache.jackrabbit.uuid.UUID;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.lucene.analysis.Analyzer;
@@ -482,7 +481,7 @@
             public Object next() {
                 NodeId nodeId = (NodeId) super.next();
                 removedNodeIds.add(nodeId);
-                return nodeId.getUUID();
+                return nodeId;
             }
         }, new AbstractIteratorDecorator(add) {
             public Object next() {
@@ -514,13 +513,9 @@
 
         // update aggregates if there are any affected
         if (aggregateRoots.size() > 0) {
-            index.update(new AbstractIteratorDecorator(
-                    aggregateRoots.keySet().iterator()) {
+            index.update(aggregateRoots.keySet().iterator(),
+            new AbstractIteratorDecorator(aggregateRoots.values().iterator()) {
                 public Object next() {
-                    return ((NodeId) super.next()).getUUID();
-                }
-            }, new AbstractIteratorDecorator(aggregateRoots.values().iterator()) {
-                public Object next() {
                     NodeState state = (NodeState) super.next();
                     try {
                         return createDocument(state, getNamespaceMappings(),
@@ -994,7 +989,7 @@
                                 doc.add(fulltextFields[k]);
                             }
                             doc.add(new Field(FieldNames.AGGREGATED_NODE_UUID,
-                                    aggregates[j].getNodeId().getUUID().toString(),
+                                    aggregates[j].getNodeId().toString(),
                                     Field.Store.NO,
                                     Field.Index.NO_NORMS));
                         }
@@ -1005,7 +1000,7 @@
             } catch (Exception e) {
                 // do not fail if aggregate cannot be created
                 log.warn("Exception while building indexing aggregate for " +
-                        "node with UUID: " + state.getNodeId().getUUID(), e);
+                        "node with id: " + state.getNodeId(), e);
             }
         }
     }
@@ -1035,7 +1030,7 @@
                 }
             } catch (Exception e) {
                 log.warn("Unable to get aggregate root for " +
-                        state.getNodeId().getUUID(), e);
+                        state.getNodeId(), e);
             }
         }
     }
@@ -1059,20 +1054,19 @@
             try {
                 IndexReader reader = index.getIndexReader();
                 try {
-                    Term aggregateUUIDs = new Term(
+                    Term aggregateIds = new Term(
                             FieldNames.AGGREGATED_NODE_UUID, "");
                     TermDocs tDocs = reader.termDocs();
                     try {
                         ItemStateManager ism = getContext().getItemStateManager();
                         for (Iterator it = removedNodeIds.iterator(); it.hasNext(); ) {
                             NodeId id = (NodeId) it.next();
-                            aggregateUUIDs = aggregateUUIDs.createTerm(
-                                    id.getUUID().toString());
-                            tDocs.seek(aggregateUUIDs);
+                            aggregateIds = aggregateIds.createTerm(id.toString());
+                            tDocs.seek(aggregateIds);
                             while (tDocs.next()) {
                                 Document doc = reader.document(tDocs.doc());
                                 String uuid = doc.get(FieldNames.UUID);
-                                NodeId nId = new NodeId(UUID.fromString(uuid));
+                                NodeId nId = NodeId.valueOf(uuid);
                                 map.put(nId, ism.getItemState(nId));
                                 found++;
                             }
Index: src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java	(working copy)
@@ -885,7 +885,7 @@
                     try {
                         ItemId id = hmgr.resolvePath(session.getQPath(node.getStringValue()));
                         if (id != null && id.denotesNode()) {
-                            uuid = ((NodeId) id).getUUID().toString();
+                            uuid = id.toString();
                         }
                     } catch (Exception e) {
                         exceptions.add(e);
Index: src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheckError.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheckError.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheckError.java	(working copy)
@@ -16,7 +16,7 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import org.apache.jackrabbit.uuid.UUID;
+import org.apache.jackrabbit.core.NodeId;
 
 import java.io.IOException;
 
@@ -31,13 +31,13 @@
     protected final String message;
 
     /**
-     * The UUID of the affected node.
+     * The id of the affected node.
      */
-    protected final UUID uuid;
+    protected final NodeId id;
 
-    ConsistencyCheckError(String message, UUID uuid) {
+    ConsistencyCheckError(String message, NodeId id) {
         this.message = message;
-        this.uuid = uuid;
+        this.id = id;
     }
 
     /**
Index: src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java	(working copy)
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.data.db;
 
+import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.data.DataIdentifier;
 import org.apache.jackrabbit.core.data.DataRecord;
 import org.apache.jackrabbit.core.data.DataStore;
@@ -23,7 +24,6 @@
 import org.apache.jackrabbit.core.persistence.bundle.util.ConnectionRecoveryManager;
 import org.apache.jackrabbit.core.persistence.bundle.util.TrackingInputStream;
 import org.apache.jackrabbit.core.persistence.bundle.util.ConnectionRecoveryManager.StreamWrapper;
-import org.apache.jackrabbit.uuid.UUID;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -174,7 +174,7 @@
         for (int i = 0; i < ConnectionRecoveryManager.TRIALS; i++) {
             try {
                 now = System.currentTimeMillis();
-                id = UUID.randomUUID().toString();
+                id = NodeId.randomNodeId().toString();
                 tempId = TEMP_PREFIX + id;
                 PreparedStatement prep = conn.executeStmt(selectMetaSQL, new Object[]{tempId});
                 ResultSet rs = prep.getResultSet();
Index: src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/value/InternalValue.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/value/InternalValue.java	(working copy)
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.value;
 
+import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.fs.FileSystemResource;
 import org.apache.jackrabbit.conversion.MalformedPathException;
@@ -24,7 +25,6 @@
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.util.ISO8601;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.value.BinaryValue;
 import org.apache.jackrabbit.value.BooleanValue;
 import org.apache.jackrabbit.value.DateValue;
@@ -145,7 +145,7 @@
             case PropertyType.LONG:
                 return create(value.getLong());
             case PropertyType.REFERENCE:
-                return create(new UUID(value.getString()));
+                return create(NodeId.valueOf(value.getString()));
             case PropertyType.NAME:
                 try {
                     return create(resolver.getQName(value.getString()));
@@ -349,7 +349,7 @@
      * @param value
      * @return the created value
      */
-    public static InternalValue create(UUID value) {
+    public static InternalValue create(NodeId value) {
         return new InternalValue(value);
     }
 
@@ -397,12 +397,12 @@
         assert val != null && type == PropertyType.BINARY;
         return (BLOBFileValue) val;
     }
-    
-    public UUID getUUID() {
+
+    public NodeId getNodeId() {
         assert val != null && type == PropertyType.REFERENCE;
-        return (UUID) val;
+        return (NodeId) val;
     }
-    
+
     public boolean getBoolean() {
         assert val != null && type == PropertyType.BOOLEAN;
         return ((Boolean) val).booleanValue();
@@ -497,7 +497,7 @@
             case PropertyType.LONG:
                 return create(Long.valueOf(s).longValue());
             case PropertyType.REFERENCE:
-                return create(new UUID(s));
+                return create(NodeId.valueOf(s));
             case PropertyType.PATH:
                 return create(PathFactoryImpl.getInstance().create(s));
             case PropertyType.NAME:
@@ -589,7 +589,7 @@
         type = PropertyType.PATH;
     }
 
-    private InternalValue(UUID value) {
+    private InternalValue(NodeId value) {
         val = value;
         type = PropertyType.REFERENCE;
     }
Index: src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java	(working copy)
@@ -1229,8 +1229,8 @@
                     // add the new 'reference'
                     InternalValue[] vals = prop.getValues();
                     for (int i = 0; vals != null && i < vals.length; i++) {
-                        NodeReferencesId refsId = new NodeReferencesId(
-                                vals[i].getUUID());
+                        NodeReferencesId refsId =
+                            new NodeReferencesId(vals[i].getNodeId());
                         if (virtualProvider != null
                                 && virtualProvider.hasNodeReferences(refsId)) {
                             continue;
@@ -1259,8 +1259,8 @@
                     // remove the old 'reference' from the target
                     InternalValue[] vals = oldProp.getValues();
                     for (int i = 0; vals != null && i < vals.length; i++) {
-                        NodeReferencesId refsId = new NodeReferencesId(
-                                vals[i].getUUID());
+                        NodeReferencesId refsId =
+                            new NodeReferencesId(vals[i].getNodeId());
                         if (virtualProvider != null
                                 && virtualProvider.hasNodeReferences(refsId)) {
                             continue;
@@ -1283,8 +1283,8 @@
                     // add the new 'reference' to the target
                     InternalValue[] vals = newProp.getValues();
                     for (int i = 0; vals != null && i < vals.length; i++) {
-                        NodeReferencesId refsId = new NodeReferencesId(
-                                vals[i].getUUID());
+                        NodeReferencesId refsId =
+                            new NodeReferencesId(vals[i].getNodeId());
                         if (virtualProvider != null
                                 && virtualProvider.hasNodeReferences(refsId)) {
                             continue;
@@ -1310,8 +1310,8 @@
                     // remove the 'reference' from the target
                     InternalValue[] vals = prop.getValues();
                     for (int i = 0; vals != null && i < vals.length; i++) {
-                        NodeReferencesId refsId = new NodeReferencesId(
-                                vals[i].getUUID());
+                        NodeReferencesId refsId =
+                            new NodeReferencesId(vals[i].getNodeId());
                         if (virtualProvider != null
                                 && virtualProvider.hasNodeReferences(refsId)) {
                             continue;
Index: src/main/java/org/apache/jackrabbit/core/state/NodeReferencesId.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/state/NodeReferencesId.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/state/NodeReferencesId.java	(working copy)
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.core.state;
 
 import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.uuid.UUID;
 
 import java.io.Serializable;
 
@@ -35,17 +34,6 @@
     private final NodeId targetId;
 
     /**
-     * Creates a new instance of this class. Takes the uuid of the target node
-     * as parameter.
-     *
-     * @param uuid uuid of target node
-     * @throws IllegalArgumentException if <code>uuid</code> is <code>null</code>.
-     */
-    public NodeReferencesId(UUID uuid) {
-        targetId = new NodeId(uuid);
-    }
-
-    /**
      * Creates a new instance of this class. Takes the id of the target node
      * as parameter.
      *
@@ -113,7 +101,7 @@
             return true;
         }
         if (obj instanceof NodeReferencesId) {
-            return targetId.getUUID().equals(((NodeReferencesId) obj).targetId.getUUID());
+            return targetId.equals(((NodeReferencesId) obj).targetId);
         }
         return false;
     }
Index: src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java	(working copy)
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.core.state;
 
 import org.apache.jackrabbit.core.ItemId;
+import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.TransactionException;
 import org.apache.jackrabbit.core.TransactionContext;
 import org.apache.jackrabbit.core.InternalXAResource;
@@ -24,7 +25,6 @@
 import org.apache.jackrabbit.core.observation.EventStateCollectionFactory;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.virtual.VirtualItemStateProvider;
-import org.apache.jackrabbit.uuid.UUID;
 
 import javax.jcr.ReferentialIntegrityException;
 import javax.jcr.PropertyType;
@@ -330,8 +330,8 @@
                 if (prop.getType() == PropertyType.REFERENCE) {
                     InternalValue[] vals = prop.getValues();
                     for (int i = 0; vals != null && i < vals.length; i++) {
-                        UUID uuid = vals[i].getUUID();
-                        NodeReferencesId refsId = new NodeReferencesId(uuid);
+                        NodeId id = vals[i].getNodeId();
+                        NodeReferencesId refsId = new NodeReferencesId(id);
                         addVirtualReference(prop.getPropertyId(), refsId);
                     }
                 }
@@ -346,16 +346,16 @@
                 if (oldProp.getType() == PropertyType.REFERENCE) {
                     InternalValue[] vals = oldProp.getValues();
                     for (int i = 0; vals != null && i < vals.length; i++) {
-                        UUID uuid = vals[i].getUUID();
-                        NodeReferencesId refsId = new NodeReferencesId(uuid);
+                        NodeId id = vals[i].getNodeId();
+                        NodeReferencesId refsId = new NodeReferencesId(id);
                         removeVirtualReference(oldProp.getPropertyId(), refsId);
                     }
                 }
                 if (newProp.getType() == PropertyType.REFERENCE) {
                     InternalValue[] vals = newProp.getValues();
                     for (int i = 0; vals != null && i < vals.length; i++) {
-                        UUID uuid = vals[i].getUUID();
-                        NodeReferencesId refsId = new NodeReferencesId(uuid);
+                        NodeId id = vals[i].getNodeId();
+                        NodeReferencesId refsId = new NodeReferencesId(id);
                         addVirtualReference(newProp.getPropertyId(), refsId);
                     }
                 }
@@ -368,8 +368,8 @@
                 if (prop.getType() == PropertyType.REFERENCE) {
                     InternalValue[] vals = prop.getValues();
                     for (int i = 0; vals != null && i < vals.length; i++) {
-                        UUID uuid = vals[i].getUUID();
-                        NodeReferencesId refsId = new NodeReferencesId(uuid);
+                        NodeId id = vals[i].getNodeId();
+                        NodeReferencesId refsId = new NodeReferencesId(id);
                         removeVirtualReference(prop.getPropertyId(), refsId);
                     }
                 }
Index: src/main/java/org/apache/jackrabbit/core/state/FineGrainedISMLocking.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/state/FineGrainedISMLocking.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/state/FineGrainedISMLocking.java	(working copy)
@@ -19,7 +19,6 @@
 import org.apache.jackrabbit.core.ItemId;
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.PropertyId;
-import org.apache.jackrabbit.uuid.UUID;
 
 import java.util.Map;
 import java.util.HashMap;
@@ -381,13 +380,13 @@
         }
 
         private static int slotIndex(ItemId id) {
-            UUID uuid;
+            NodeId nodeId;
             if (id.denotesNode()) {
-                uuid = ((NodeId) id).getUUID();
+                nodeId = (NodeId) id;
             } else {
-                uuid = ((PropertyId) id).getParentId().getUUID();
+                nodeId = ((PropertyId) id).getParentId();
             }
-            return ((int) uuid.getLeastSignificantBits()) & 0xf;
+            return ((int) nodeId.getLeastSignificantBits()) & 0xf;
         }
     }
 }
Index: src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java	(working copy)
@@ -345,8 +345,8 @@
         if (v == null) {
             return null;
         } else {
-            return (Version)
-                    ((SessionImpl) history.getSession()).getNodeByUUID(v.getId().getUUID());
+            SessionImpl session = (SessionImpl) history.getSession();
+            return (Version) session.getNodeById(v.getId());
         }
     }
 
Index: src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java	(working copy)
@@ -25,7 +25,6 @@
 import org.apache.jackrabbit.core.state.LocalItemStateManager;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.name.NameConstants;
 import org.apache.jackrabbit.name.NameFactoryImpl;
 import org.slf4j.Logger;
@@ -299,7 +298,7 @@
         WriteOperation operation = startWriteOperation();
         try {
             // create deep path
-            String uuid = node.getNodeId().getUUID().toString();
+            String uuid = node.getNodeId().toString();
             NodeStateEx root = historyRoot;
             for (int i = 0; i < 3; i++) {
                 Name name = NameFactoryImpl.getInstance().create(Name.NS_DEFAULT_URI, uuid.substring(i * 2, i * 2 + 2));
@@ -317,7 +316,7 @@
 
             // create new history node in the persistent state
             InternalVersionHistoryImpl hist = InternalVersionHistoryImpl.create(
-                    this, root, new NodeId(UUID.randomUUID()), historyNodeName, node);
+                    this, root, NodeId.randomNodeId(), historyNodeName, node);
 
             // end update
             operation.save();
@@ -344,7 +343,7 @@
     private NodeId getVersionHistoryId(NodeState node)
             throws RepositoryException {
         // build and traverse path
-        String uuid = node.getNodeId().getUUID().toString();
+        String uuid = node.getNodeId().toString();
         NodeStateEx n = historyRoot;
         for (int i = 0; i < 3; i++) {
             Name name = NameFactoryImpl.getInstance().create(Name.NS_DEFAULT_URI, uuid.substring(i * 2, i * 2 + 2));
Index: src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistory.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistory.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistory.java	(working copy)
@@ -18,10 +18,8 @@
 
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.uuid.UUID;
 
 import javax.jcr.version.VersionException;
-import java.util.Iterator;
 
 /**
  * This interface defines the internal version history.
@@ -85,11 +83,11 @@
     int getNumVersions();
 
     /**
-     * Returns the UUID of the versionable node that this history belongs to.
+     * Returns the id of the versionable node that this history belongs to.
      *
-     * @return the UUID of the versionable node.
+     * @return the id of the versionable node.
      */
-    UUID getVersionableUUID();
+    NodeId getVersionableId();
 
     /**
      * Returns a string  iterator over all version labels that exist in this
Index: src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java	(working copy)
@@ -135,8 +135,8 @@
             if (values != null) {
                 InternalVersion[] versions = new InternalVersion[values.length];
                 for (int i = 0; i < values.length; i++) {
-                    NodeId vId = new NodeId(values[i].getUUID());
-                    versions[i] = versionHistory.getVersion(vId);
+                    versions[i] =
+                        versionHistory.getVersion(values[i].getNodeId());
                 }
                 return versions;
             } else {
@@ -155,8 +155,7 @@
         if (values != null) {
             InternalVersion[] versions = new InternalVersion[values.length];
             for (int i = 0; i < values.length; i++) {
-                NodeId vId = new NodeId(values[i].getUUID());
-                versions[i] = versionHistory.getVersion(vId);
+                versions[i] = versionHistory.getVersion(values[i].getNodeId());
             }
             return versions;
         } else {
@@ -223,7 +222,7 @@
         InternalValue[] values = new InternalValue[cessors.size()];
         for (int i = 0; i < values.length; i++) {
             values[i] = InternalValue.create(
-                    ((InternalVersion) cessors.get(i)).getId().getUUID());
+                    ((InternalVersion) cessors.get(i)).getId());
         }
         node.setPropertyValues(propname, PropertyType.STRING, values);
         if (store) {
@@ -390,8 +389,8 @@
         InternalValue[] values = node.getPropertyValues(NameConstants.JCR_PREDECESSORS);
         if (values != null) {
             for (int i = 0; i < values.length; i++) {
-                NodeId vId = new NodeId(values[i].getUUID());
-                InternalVersionImpl v = (InternalVersionImpl) versionHistory.getVersion(vId);
+                InternalVersionImpl v = (InternalVersionImpl)
+                    versionHistory.getVersion(values[i].getNodeId());
                 v.internalAddSuccessor(this, false);
             }
         }
Index: src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNode.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNode.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNode.java	(working copy)
@@ -16,9 +16,9 @@
  */
 package org.apache.jackrabbit.core.version;
 
+import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.uuid.UUID;
 
 import javax.jcr.version.VersionException;
 
@@ -46,11 +46,11 @@
     PropertyState[] getFrozenProperties();
 
     /**
-     * Returns the frozen UUID.
+     * Returns the frozen node id.
      *
-     * @return the frozen uuid.
+     * @return the frozen id.
      */
-    UUID getFrozenUUID();
+    NodeId getFrozenId();
 
     /**
      * Returns the name of frozen primary type.
@@ -68,10 +68,10 @@
 
     /**
      * Checks if this frozen node has the frozen version history
-     * @param uuid
+     * @param id frozen id
      * @return <code>true</code> if this node has the history;
      *         <code>false</code> otherwise.
      */
-    boolean hasFrozenHistory(UUID uuid);
+    boolean hasFrozenHistory(NodeId id);
 
 }
Index: src/main/java/org/apache/jackrabbit/core/version/InternalFrozenVHImpl.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/version/InternalFrozenVHImpl.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/version/InternalFrozenVHImpl.java	(working copy)
@@ -58,7 +58,7 @@
      * {@inheritDoc}
      */
     public NodeId getVersionHistoryId() {
-        return new NodeId(node.getPropertyValue(NameConstants.JCR_CHILDVERSIONHISTORY).getUUID());
+        return node.getPropertyValue(NameConstants.JCR_CHILDVERSIONHISTORY).getNodeId();
     }
 
     /**
@@ -77,7 +77,7 @@
      * {@inheritDoc}
      */
     public NodeId getBaseVersionId() {
-        return new NodeId(node.getPropertyValue(NameConstants.JCR_BASEVERSION).getUUID());
+        return node.getPropertyValue(NameConstants.JCR_BASEVERSION).getNodeId();
     }
 
     /**
Index: src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java	(working copy)
@@ -31,7 +31,6 @@
 import org.apache.jackrabbit.core.state.UpdatableItemStateManager;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.name.NameConstants;
 
 import java.util.HashSet;
@@ -435,7 +434,7 @@
 
         NodeStateEx node = createChildNode(nodeName, nodeTypeName, id);
         if (referenceable) {
-            node.setPropertyValue(NameConstants.JCR_UUID, InternalValue.create(node.getNodeId().getUUID().toString()));
+            node.setPropertyValue(NameConstants.JCR_UUID, InternalValue.create(node.getNodeId().toString()));
         }
         return node;
     }
@@ -452,7 +451,7 @@
         NodeId parentId = nodeState.getNodeId();
         // create a new node state
         if (id == null) {
-            id = new NodeId(UUID.randomUUID());
+            id = NodeId.randomNodeId();
         }
         NodeState state = stateMgr.createNew(id, nodeTypeName, parentId);
 
Index: src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java	(working copy)
@@ -24,7 +24,6 @@
 import org.apache.jackrabbit.core.state.NodeState.ChildNodeEntry;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.name.NameConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -132,12 +131,11 @@
                 PropertyState pState = labels[i];
                 if (pState.getType() == PropertyType.REFERENCE) {
                     Name labelName = pState.getName();
-                    UUID ref = pState.getValues()[0].getUUID();
-                    NodeId id = new NodeId(ref);
+                    NodeId id = pState.getValues()[0].getNodeId();
                     if (node.getState().hasChildNodeEntry(id)) {
                         labelCache.put(labelName, node.getState().getChildNodeEntry(id).getName());
                     } else {
-                        log.warn("Error while resolving label reference. Version missing: " + ref);
+                        log.warn("Error while resolving label reference. Version missing: " + id);
                     }
                 }
             }
@@ -321,8 +319,8 @@
     /**
      * {@inheritDoc}
      */
-    public UUID getVersionableUUID() {
-        return versionableId.getUUID();
+    public NodeId getVersionableId() {
+        return versionableId;
     }
 
     /**
@@ -428,7 +426,7 @@
             if (version == null) {
                 labelNode.removeProperty(label);
             } else {
-                labelNode.setPropertyValue(label, InternalValue.create(version.getId().getUUID()));
+                labelNode.setPropertyValue(label, InternalValue.create(version.getId()));
             }
             labelNode.store();
         } catch (RepositoryException e) {
@@ -463,15 +461,15 @@
         Value[] preds = src.getProperty(NameConstants.JCR_PREDECESSORS).getValues();
         InternalValue[] predecessors = new InternalValue[preds.length];
         for (int i = 0; i < preds.length; i++) {
-            UUID predId = UUID.fromString(preds[i].getString());
+            NodeId predId = NodeId.valueOf(preds[i].getString());
             // check if version exist
-            if (!nameCache.containsValue(new NodeId(predId))) {
+            if (!nameCache.containsValue(predId)) {
                 throw new RepositoryException("invalid predecessor in source node");
             }
             predecessors[i] = InternalValue.create(predId);
         }
 
-        NodeId versionId = new NodeId(UUID.randomUUID());
+        NodeId versionId = NodeId.randomNodeId();
         NodeStateEx vNode = node.addNode(name, NameConstants.NT_VERSION, versionId, true);
 
         // initialize 'created', 'predecessors' and 'successors'
@@ -517,14 +515,14 @@
         NodeStateEx pNode = parent.addNode(name, NameConstants.NT_VERSIONHISTORY, historyId, true);
 
         // set the versionable uuid
-        String versionableUUID = nodeState.getNodeId().getUUID().toString();
+        String versionableUUID = nodeState.getNodeId().toString();
         pNode.setPropertyValue(NameConstants.JCR_VERSIONABLEUUID, InternalValue.create(versionableUUID));
 
         // create label node
         pNode.addNode(NameConstants.JCR_VERSIONLABELS, NameConstants.NT_VERSIONLABELS, null, false);
 
         // create root version
-        NodeId versionId = new NodeId(UUID.randomUUID());
+        NodeId versionId = NodeId.randomNodeId();
         NodeStateEx vNode = pNode.addNode(NameConstants.JCR_ROOTVERSION, NameConstants.NT_VERSION, versionId, true);
 
         // initialize 'created' and 'predecessors'
Index: src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java	(working copy)
@@ -25,7 +25,6 @@
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.name.NameConstants;
 
 import javax.jcr.NodeIterator;
@@ -72,9 +71,9 @@
     private InternalFreeze[] frozenNodes = null;
 
     /**
-     * the frozen uuid of the original node
+     * the frozen id of the original node
      */
-    private UUID frozenUUID = null;
+    private NodeId frozenId = null;
 
     /**
      * the frozen primary type of the orginal node
@@ -110,7 +109,7 @@
             PropertyState prop = props[i];
             if (prop.getName().equals(NameConstants.JCR_FROZENUUID)) {
                 // special property
-                frozenUUID = UUID.fromString(node.getPropertyValue(NameConstants.JCR_FROZENUUID).getString());
+                frozenId = NodeId.valueOf(node.getPropertyValue(NameConstants.JCR_FROZENUUID).getString());
             } else if (prop.getName().equals(NameConstants.JCR_FROZENPRIMARYTYPE)) {
                 // special property
                 frozenPrimaryType = node.getPropertyValue(NameConstants.JCR_FROZENPRIMARYTYPE).getQName();
@@ -185,9 +184,8 @@
     /**
      * {@inheritDoc}
      */
-    public boolean hasFrozenHistory(UUID uuid) {
+    public boolean hasFrozenHistory(NodeId id) {
         try {
-            NodeId id = new NodeId(uuid);
             InternalFreeze[] frozen = getFrozenChildNodes();
             for (int i=0; i<frozen.length; i++) {
                 if (frozen[i] instanceof InternalFrozenVersionHistory &&
@@ -212,8 +210,8 @@
     /**
      * {@inheritDoc}
      */
-    public UUID getFrozenUUID() {
-        return frozenUUID;
+    public NodeId getFrozenId() {
+        return frozenId;
     }
 
     /**
@@ -271,7 +269,7 @@
 
         // initialize the internal properties
         node.setPropertyValue(NameConstants.JCR_FROZENUUID,
-                InternalValue.create(src.internalGetUUID().toString()));
+                InternalValue.create(src.getId().toString()));
         node.setPropertyValue(NameConstants.JCR_FROZENPRIMARYTYPE,
                 InternalValue.create(((NodeTypeImpl) src.getPrimaryNodeType()).getQName()));
         if (src.hasProperty(NameConstants.JCR_MIXINTYPES)) {
@@ -335,7 +333,7 @@
                         // create frozen versionable child
                         NodeStateEx newChild = node.addNode(child.getQName(), NameConstants.NT_VERSIONEDCHILD, null, false);
                         newChild.setPropertyValue(NameConstants.JCR_CHILDVERSIONHISTORY,
-                                InternalValue.create(new UUID(child.getVersionHistory().getUUID())));
+                                InternalValue.create(NodeId.valueOf(child.getVersionHistory().getUUID())));
                         /*
                         newChild.setPropertyValue(JCR_BASEVERSION,
                                 InternalValue.create(child.getBaseVersion().getUUID()));
Index: src/main/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java	(working copy)
@@ -247,7 +247,7 @@
      * {@inheritDoc}
      */
     public String getVersionableUUID() throws RepositoryException {
-        return getInternalVersionHistory().getVersionableUUID().toString();
+        return getInternalVersionHistory().getVersionableId().toString();
     }
 
     /**
Index: src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java	(working copy)
@@ -22,7 +22,6 @@
 import org.apache.jackrabbit.core.util.ReferenceChangeTracker;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.value.ReferenceValue;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.name.NameFactoryImpl;
 import org.apache.jackrabbit.name.NameConstants;
 import org.slf4j.Logger;
@@ -119,8 +118,7 @@
         }
 
         // add node
-        UUID uuid = (id == null) ? null : id.getUUID();
-        node = parent.addNode(nodeName, nodeTypeName, uuid);
+        node = parent.addNode(nodeName, nodeTypeName, id);
         // add mixins
         if (mixinNames != null) {
             for (int i = 0; i < mixinNames.length; i++) {
@@ -141,7 +139,7 @@
                     nodeInfo.getNodeTypeName(), nodeInfo.getMixinNames(), null);
             // remember uuid mapping
             if (node.isNodeType(NameConstants.MIX_REFERENCEABLE)) {
-                refTracker.mappedUUID(nodeInfo.getId().getUUID(), node.getNodeId().getUUID());
+                refTracker.mappedId(nodeInfo.getId(), node.getNodeId());
             }
         } else if (uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW) {
             String msg = "a node with uuid " + nodeInfo.getId() + " already exists!";
@@ -299,10 +297,10 @@
                 Value[] newVals = new Value[values.length];
                 for (int i = 0; i < values.length; i++) {
                     Value val = values[i];
-                    UUID original = UUID.fromString(val.getString());
-                    UUID adjusted = refTracker.getMappedUUID(original);
+                    NodeId original = NodeId.valueOf(val.getString());
+                    NodeId adjusted = refTracker.getMappedId(original);
                     if (adjusted != null) {
-                        newVals[i] = new ReferenceValue(session.getNodeByUUID(adjusted));
+                        newVals[i] = new ReferenceValue(session.getNodeById(adjusted));
                     } else {
                         // reference doesn't need adjusting, just copy old value
                         newVals[i] = val;
@@ -311,10 +309,10 @@
                 prop.setValue(newVals);
             } else {
                 Value val = prop.getValue();
-                UUID original = UUID.fromString(val.getString());
-                UUID adjusted = refTracker.getMappedUUID(original);
+                NodeId original = NodeId.valueOf(val.getString());
+                NodeId adjusted = refTracker.getMappedId(original);
                 if (adjusted != null) {
-                    prop.setValue(session.getNodeByUUID(adjusted));
+                    prop.setValue(session.getNodeById(adjusted));
                 }
             }
         }
Index: src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java	(working copy)
@@ -35,7 +35,6 @@
 import org.apache.jackrabbit.conversion.MalformedPathException;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.name.NameFactoryImpl;
 import org.apache.jackrabbit.name.NameConstants;
 import org.slf4j.Logger;
@@ -159,7 +158,7 @@
             // remember uuid mapping
             EffectiveNodeType ent = itemOps.getEffectiveNodeType(node);
             if (ent.includesNodeType(NameConstants.MIX_REFERENCEABLE)) {
-                refTracker.mappedUUID(nodeInfo.getId().getUUID(), node.getNodeId().getUUID());
+                refTracker.mappedId(nodeInfo.getId(), node.getNodeId());
             }
         } else if (uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW) {
             String msg = "a node with uuid " + nodeInfo.getId()
@@ -313,17 +312,17 @@
             // jcr:versionHistory
             conditionalAddProperty(
                     node, NameConstants.JCR_VERSIONHISTORY, PropertyType.REFERENCE, false,
-                    InternalValue.create(new UUID(history.getUUID())));
+                    InternalValue.create(NodeId.valueOf(history.getUUID())));
 
             // jcr:baseVersion
             conditionalAddProperty(
                     node, NameConstants.JCR_BASEVERSION, PropertyType.REFERENCE, false,
-                    InternalValue.create(new UUID(rootVersion.getUUID())));
+                    InternalValue.create(NodeId.valueOf(rootVersion.getUUID())));
 
             // jcr:predecessors
             conditionalAddProperty(
                     node, NameConstants.JCR_PREDECESSORS, PropertyType.REFERENCE, true,
-                    InternalValue.create(new UUID(rootVersion.getUUID())));
+                    InternalValue.create(NodeId.valueOf(rootVersion.getUUID())));
 
             // jcr:isCheckedOut
             conditionalAddProperty(
@@ -624,8 +623,8 @@
                 InternalValue[] newVals = new InternalValue[values.length];
                 for (int i = 0; i < values.length; i++) {
                     InternalValue val = values[i];
-                    UUID original = val.getUUID();
-                    UUID adjusted = refTracker.getMappedUUID(original);
+                    NodeId original = val.getNodeId();
+                    NodeId adjusted = refTracker.getMappedId(original);
                     if (adjusted != null) {
                         newVals[i] = InternalValue.create(adjusted);
                         modified = true;
Index: src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java	(working copy)
@@ -739,7 +739,7 @@
                 while (iter.hasNext()) {
                     VersionImpl v = (VersionImpl) iter.next();
                     try {
-                        NodeImpl node = (NodeImpl) session.getNodeByUUID(v.getFrozenNode().getFrozenUUID());
+                        NodeImpl node = (NodeImpl) session.getNodeById(v.getFrozenNode().getFrozenId());
                         restored = node.internalRestore(v, vsel, removeExisting);
                         // remove restored versions from set
                         for (int i = 0; i < restored.length; i++) {
Index: src/main/java/org/apache/jackrabbit/core/ItemImpl.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/ItemImpl.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/ItemImpl.java	(working copy)
@@ -36,7 +36,6 @@
 import org.apache.jackrabbit.core.version.VersionManager;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.util.Text;
 import org.apache.jackrabbit.name.NameConstants;
 import org.slf4j.Logger;
@@ -591,8 +590,8 @@
                                 boolean satisfied = false;
                                 String constraintViolationMsg = null;
                                 try {
-                                    UUID targetUUID = values[i].getUUID();
-                                    Node targetNode = session.getNodeByUUID(targetUUID);
+                                    NodeId id = values[i].getNodeId();
+                                    Node targetNode = session.getNodeById(id);
                                     /**
                                      * constraints are OR-ed, i.e. at least one
                                      * has to be satisfied
@@ -784,11 +783,11 @@
                         if (vh == null) {
                             vh = vMgr.createVersionHistory(session, nodeState);
                         }
-                        node.internalSetProperty(NameConstants.JCR_VERSIONHISTORY, InternalValue.create(new UUID(vh.getUUID())));
-                        node.internalSetProperty(NameConstants.JCR_BASEVERSION, InternalValue.create(new UUID(vh.getRootVersion().getUUID())));
+                        node.internalSetProperty(NameConstants.JCR_VERSIONHISTORY, InternalValue.create(NodeId.valueOf(vh.getUUID())));
+                        node.internalSetProperty(NameConstants.JCR_BASEVERSION, InternalValue.create(NodeId.valueOf(vh.getRootVersion().getUUID())));
                         node.internalSetProperty(NameConstants.JCR_ISCHECKEDOUT, InternalValue.create(true));
                         node.internalSetProperty(NameConstants.JCR_PREDECESSORS,
-                                new InternalValue[]{InternalValue.create(new UUID(vh.getRootVersion().getUUID()))});
+                                new InternalValue[]{InternalValue.create(NodeId.valueOf(vh.getRootVersion().getUUID()))});
                         createdTransientState = true;
                     }
                 }
Index: src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java	(working copy)
@@ -123,7 +123,7 @@
                 writeInt(index);
             } else {
                 writeByte(UUID_LITERAL);
-                write(nodeId.getUUID().getRawBytes());
+                write(nodeId.getRawBytes());
             }
         }
     }
@@ -222,7 +222,7 @@
         } else if (uuidType == UUID_LITERAL) {
             byte[] b = new byte[Constants.UUID_BYTE_LENGTH];
             readFully(b);
-            NodeId nodeId = new NodeId(new UUID(b));
+            NodeId nodeId = new NodeId(b);
             uuidIndex.add(nodeId);
             return nodeId;
         } else {
Index: src/main/java/org/apache/jackrabbit/core/util/ReferenceChangeTracker.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/util/ReferenceChangeTracker.java	(revision 597523)
+++ src/main/java/org/apache/jackrabbit/core/util/ReferenceChangeTracker.java	(working copy)
@@ -16,7 +16,7 @@
  */
 package org.apache.jackrabbit.core.util;
 
-import org.apache.jackrabbit.uuid.UUID;
+import org.apache.jackrabbit.core.NodeId;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -30,9 +30,9 @@
  */
 public class ReferenceChangeTracker {
     /**
-     * mapping <original uuid> to <new uuid> of mix:referenceable nodes
+     * mapping <original id> to <new id> of mix:referenceable nodes
      */
-    private final HashMap uuidMap = new HashMap();
+    private final HashMap idMap = new HashMap();
     /**
      * list of processed reference properties that might need correcting
      */
@@ -48,19 +48,19 @@
      * Resets all internal state.
      */
     public void clear() {
-        uuidMap.clear();
+        idMap.clear();
         references.clear();
     }
 
     /**
-     * Store the given uuid mapping for later lookup using
-     * <code>{@link #getMappedUUID(UUID)}</code>.
+     * Store the given node id mapping for later lookup using
+     * <code>{@link #getMappedId(NodeId)}</code>.
      *
-     * @param oldUUID old uuid
-     * @param newUUID new uuid
+     * @param oldId old id
+     * @param newId new id
      */
-    public void mappedUUID(UUID oldUUID, UUID newUUID) {
-        uuidMap.put(oldUUID, newUUID);
+    public void mappedId(NodeId oldId, NodeId newId) {
+        idMap.put(oldId, newId);
     }
 
     /**
@@ -74,15 +74,15 @@
     }
 
     /**
-     * Returns the new UUID to which <code>oldUUID</code> has been mapped
+     * Returns the new node id to which <code>oldId</code> has been mapped
      * or <code>null</code> if no such mapping exists.
      *
-     * @param oldUUID old uuid
-     * @return mapped new uuid or <code>null</code> if no such mapping exists
-     * @see #mappedUUID(UUID, UUID)
+     * @param oldId old node id
+     * @return mapped new node id or <code>null</code> if no such mapping exists
+     * @see #mappedId(NodeId, NodeId)
      */
-    public UUID getMappedUUID(UUID oldUUID) {
-        return (UUID) uuidMap.get(oldUUID);
+    public NodeId getMappedId(NodeId oldId) {
+        return (NodeId) idMap.get(oldId);
     }
 
     /**
