housekeeping and a nonfunctional topological sort