Index: build.xml
===================================================================
--- build.xml	(revision 1029)
+++ build.xml	(working copy)
@@ -114,7 +114,7 @@
 		</tstamp>
 
         <svn><info path="${basedir}" revisionProperty="revisionVersion" /></svn>
-        <property name="build.version" value="${revisionVersion}" />
+        <property name="build.version" value="3.1" />
 	</target>
 
 
Index: src/com/google/appengine/api/datastore/Key_CustomFieldSerializer.java
===================================================================
--- src/com/google/appengine/api/datastore/Key_CustomFieldSerializer.java	(revision 1029)
+++ src/com/google/appengine/api/datastore/Key_CustomFieldSerializer.java	(working copy)
@@ -1,5 +1,6 @@
 package com.google.appengine.api.datastore;
 
+import com.google.appengine.api.NamespaceManager;
 import com.google.gwt.user.client.rpc.SerializationException;
 import com.google.gwt.user.client.rpc.SerializationStreamReader;
 import com.google.gwt.user.client.rpc.SerializationStreamWriter;
@@ -23,11 +24,24 @@
 		String kind = streamReader.readString();
 		long id = streamReader.readLong();
 		String name = streamReader.readString();
-
-		if (name == null)
-			return KeyFactory.createKey(parent, kind, id);
-		else
-			return KeyFactory.createKey(parent, kind, name);
+		String namespace = streamReader.readString();
+		if (namespace != null) {
+			String origNamespace = NamespaceManager.get();
+			try {
+				NamespaceManager.set(namespace);
+				if (name == null)
+					return KeyFactory.createKey(parent, kind, id);
+				else
+					return KeyFactory.createKey(parent, kind, name);
+			} finally {
+				NamespaceManager.set(origNamespace);
+			}
+		} else {
+			if (name == null)
+				return KeyFactory.createKey(parent, kind, id);
+			else
+				return KeyFactory.createKey(parent, kind, name);
+		}
 	}
 
 	public static void serialize(SerializationStreamWriter streamWriter, Key instance)
@@ -37,5 +51,6 @@
 		streamWriter.writeString(instance.getKind());
 		streamWriter.writeLong(instance.getId());
 		streamWriter.writeString(instance.getName());
+		streamWriter.writeString(instance.getNamespace());
 	}
 }
Index: super/com/google/appengine/api/NamespaceManager.java
===================================================================
--- super/com/google/appengine/api/NamespaceManager.java	(revision 0)
+++ super/com/google/appengine/api/NamespaceManager.java	(revision 0)
@@ -0,0 +1,13 @@
+package com.google.appengine.api;
+
+public class NamespaceManager {
+	static private String namespace;
+	
+	public static String get() {
+		return namespace;
+	}
+	
+	public static void set(String newnamespace) {
+		namespace = newnamespace;
+	}
+}
Index: super/com/google/appengine/api/datastore/Key.java
===================================================================
--- super/com/google/appengine/api/datastore/Key.java	(revision 1029)
+++ super/com/google/appengine/api/datastore/Key.java	(working copy)
@@ -19,6 +19,7 @@
 	private String kind;
 	private long id;
 	private String name;
+	public String namespace;
 
 	@SuppressWarnings("unused")
 	private Key()
@@ -134,6 +135,11 @@
 	{
 		return name;
 	}
+	
+	public String getNamespace()
+	{
+		return namespace;
+	}
 
 	public Key getChild(String kind, long id)
 	{
Index: super/com/google/appengine/api/datastore/KeyFactory.java
===================================================================
--- super/com/google/appengine/api/datastore/KeyFactory.java	(revision 1029)
+++ super/com/google/appengine/api/datastore/KeyFactory.java	(working copy)
@@ -1,5 +1,7 @@
 package com.google.appengine.api.datastore;
 
+import com.google.appengine.api.NamespaceManager;
+
 /**
  * GWT emulation class, with most of the methods from KeyFactory.
  * Does not support the keyToString()/stringToKey() methods.
@@ -52,8 +54,11 @@
 	{
 		if (id == 0L)
 			throw new IllegalArgumentException("id cannot be zero");
-		else
-			return new Key(kind, parent, id);
+		else {
+			Key key = new Key(kind, parent, id);
+			key.namespace = NamespaceManager.get();
+			return key;
+		}
 	}
 
 	public static Key createKey(String kind, String name)
@@ -65,8 +70,11 @@
 	{
 		if (name == null || name.length() == 0)
 			throw new IllegalArgumentException("name cannot be null or empty");
-		else
-			return new Key(kind, parent, name);
+		else {
+			Key key = new Key(kind, parent, name);
+			key.namespace = NamespaceManager.get();
+			return key;
+		}
 	}
 
 	private KeyFactory()
