Refactored the Scopes into a ScopeChain (similar to InheritanceChain).