enhancements to handle serialization of circular references
added distinct on in clause for assocations