code generation refactoring and restyling