      * value.
      */
     
-    public function encodeObject(obj:Object, parentNode:XMLNode=null, rootTag:String=null, rootQName:XObjQName=null):XMLDocument
+    private var recursionMap:Dictionary;
+    
+    public function encodeObject(obj:Object, parentNode:XMLNode=null, rootTag:String=null, rootQName:XObjQName=null, referenceOnly:Boolean=false):XMLDocument
     {
         var qname:XObjQName = rootQName;
+        
+        recursionMap = new Dictionary(true);
         
         // is obj a root holder?
         /*if (XObjMetadata.METADATA_PROPERTY in obj)

    internal function encodeValue(obj:Object, q:*, parentNode:XMLNode, recurse:Boolean=true, referenceOnly:Boolean=false, isRoot:Boolean=false):XMLNode
    {
        var qname:XObjQName = new XObjQName();
        
        if (q is XObjQName)
            qname = q;
        else if (q is QName)

            //TODO: synthesize the attrList structure
            
        }
        else if (("id" in obj) && obj["id"]) // special case id property in non __attributes case
        {
            attrList.push({propname:"id"});
        }
