                             // remove elements we've handled to speed up the next iteration
                             // makes a HUGE difference on large collections of objects
                             properties.splice(k,1);
-                            encodeValue(obj[propName], entry.qname, myElement, recurse, XObjMetadata.isPropByRef(classInfo, propName));
+                            encodeValue(obj[propName], entry.qname, myElement, recurse, XObjMetadata.isPropByRef(classInfo, propName), false, propName);
                             break;
                         }
                     }

        }
        else if (isRoot)
        {
            return internal_encodeValue(obj, qname, parentNode, true, referenceOnly);
        }
        else if (referenceOnly)
        {
            return internal_encodeValue(obj, qname, parentNode, false, true);
        }
        else if (recurse)
        {

        return encodeValue(obj, q, parentNode, false, true);
    }
    
    internal function encodeValue(obj:Object, q:*, parentNode:XML, recurse:Boolean=true, referenceOnly:Boolean=false, isRoot:Boolean=false, propName:String=null):XML
    {
        var qname:XObjQName;
        
