Minor refactoring
MongoDB support part 2