Refactors history and how the database is stored