Fixed handling of scopes