Correcting call-by-reference issues