Small codegen refactors