WIP refactoring generator code