Performance improvements for ObjectId conversion.