Some generator refactoring