Fix some more codegen bugs