toJSON and toXML updates