Bug fixes for the API generator
diff --git a/planetstack/apigen/modelgen b/planetstack/apigen/modelgen
index e0def4b..db9ae84 100755
--- a/planetstack/apigen/modelgen
+++ b/planetstack/apigen/modelgen
@@ -2,6 +2,7 @@
 
 import os
 import pdb
+import copy
 import sys
 import json
 import re
@@ -69,8 +70,8 @@
 
 	def compute_links(self):
 		for obj in self.values():
-			if (str(obj).lower()=='user'):
-				pdb.set_trace()
+			#if (str(obj).lower()=='user'):
+			#	pdb.set_trace()
 			fields = obj.model._meta.fields
 			for f in fields:
 				if type(f)==ForeignKey and f.name in self.keys():
@@ -86,9 +87,11 @@
 					related_model_name = f.m2m_db_table().rsplit('_',1)[-1]
 
 				if related_model_name in self.keys():
+			#		pdb.set_trace()
 					refobj = self[related_model_name]
-					obj.multi=True
-					refobj.refs.append(obj)
+					cobj = copy.deepcopy(obj)
+					cobj.multi=True
+					refobj.refs.append(cobj)
 
 			
 def main():