This is copy/pasted from node-mongodb-native