Pass some parameters by reference to functions. Small cleanup
fix some code analyzer warnings