mostly a rewrite. found the cause of the segfaulting to be NULL pointers. resolve to use references instead of pointers from now on.