Generator refactoring