Cleaned up dijkstra's code.