Refactoring of Generator.cs