Refactorings to use .command and to fix issues for mongos sharding