Fixing the implementation of topological sorting in DAGs.

Fixed the implementation of topological sorting, which we'll need for dependency trees.  (I was making a stupid mistake, and just using BFS as if that would actually solve the problem. In fact [remembering CS 5] I need a queue, <smacks forehead>).