Faster universe checking

This mainly fixes a scoping issue which made the cycle checker search
too many times.

Fixes #1649
Merge pull request #1666 from edwinb/universes

Faster universe checking