reworked codegen for reference parameters