Refactor models and db schema