changed a bunch of pointers to references, still more to be changed