Cleanup of Dijkstra's algorithm.