Refactoring the ModelGenerator