Update mongodb and fix upsert statements