major refactoring of the database