Implemented BSON serialization