Moved ScopeStack internals inside.