Remove manual caching in globals

This PR takes advantage of `lru_cache` to remove many uses of the `global` keyword.

I've always been at war with `global` :-)