Minor performance improvements for MongoDB, some clean up as well.