various codegen improvements