finished restructuring of generated code