Introduce abstractions for global scopes.

Part of #2811.