Fix some pass by reference issues