Merging changes from MongoClient branch to fix issues with mongodb driver version >=1.3