refactors loop handling, perf degradation is gone
precise implementation of canCauseLoops
import norefs._