Proper cycle detections

Now it's done using Tarjan's algorithm to detect strongly connected
components. The cycles are computed only when a module is resolved and
the result is cached.