Refactor ScopeNameList and ScopeNameLevel.