Stop using pointers for everything and add some tests