Fix pass by reference errors