Fixes some issues related to mongo relations.
Merge pull request #1026 from jails/bug/mongo-relations

Fixes some issues related to mongo relations.