Faster universe checking

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