Edge case fixes

Stupid circular loops. Resolved by reducing the graph multiple times
until the size converges, and making sure the reduction doesn't resolve
into a loopback.