fix
topo sort dependencies before factoring
Undo inline topo sort

Signed-off-by: Terin Stock <terinjokes@gmail.com>