Split up into modules and refactor simple O(N^2) Dijkstra.