Handle cyclic dependencies

* The PR depends on #96.
* Please review only the second commit.
I think you could reach 10 in real world. 50 maybe is more realistic?