Refactoring: entities framework