Minor refactoring of the mongo client