Added topo sort of tasks (completely untested).