Some small refactoring to make the generator more generic