Abstracted exact and heuristic distance methods into separate functions and changed functions which can return nil to also return a found boolean.