Fixes some issues related to mongo relations.