Moved some stuff around within the dijkstra implementation