Mongodb fixes

Fixes for MongoDB support.