changed the T4 file and adapted the state machine to work with auto-generated code