Optimize functions to use pointers to structs.