Changed pass by val/ref for several things.