Refactoring and abstraction of models