Switch to pointers instead of references everywhere.