MongoDB support part 12.1
Minor refactorings