Refactor mongo database.