Small codegen refactor