Fix problem that would duplicate objects in MongoDB databases