Refactor NameScope.