diff --git a/src/Entity/SavedSearchType.php b/src/Entity/SavedSearchType.php
index df9f818..3a66700 100644
--- a/src/Entity/SavedSearchType.php
+++ b/src/Entity/SavedSearchType.php
@@ -500,9 +500,9 @@ public function onDependencyRemoval(array $dependencies) {
     $call_on_removal = [];
 
     foreach ($dependencies as $dependency_type => $dependency_objects) {
-      // Annoyingly, modules and theme dependencies come not keyed by dependency
-      // name here, while entities do. Flip the array for modules and themes to
-      // make the code simpler.
+      // Annoyingly, modules and theme dependencies do not come keyed by
+      // dependency  name here, while entities do. Flip the array for modules
+      // and themes to make the code simpler.
       if (in_array($dependency_type, ['module', 'theme'])) {
         $dependency_objects = array_flip($dependency_objects);
       }
@@ -531,7 +531,7 @@ public function onDependencyRemoval(array $dependencies) {
           // However this plays out, it will lead to a change.
           $changed = TRUE;
 
-          foreach ($dependency_sources['optional'] as $plugin_type => $plugins) {
+          foreach ($dependency_sources['optional'] as $plugins) {
             // Type entities currently have no soft dependencies, so this has to
             // be a plugin dependency. We want to call onDependencyRemoval() on
             // that plugin.
@@ -540,7 +540,7 @@ public function onDependencyRemoval(array $dependencies) {
             $plugins = array_intersect_key($plugins, $all_plugins);
 
             foreach ($plugins as $plugin_id => $plugin) {
-              $call_on_removal[$plugin_type][$plugin_id][$dependency_type][$name] = $dependency_objects[$name];
+              $call_on_removal[$plugin_id][$dependency_type][$name] = $dependency_objects[$name];
             }
           }
         }
@@ -550,19 +550,17 @@ public function onDependencyRemoval(array $dependencies) {
     // Now for all plugins with optional dependencies (stored in
     // $call_on_removal, mapped to their removed dependencies) call their
     // onDependencyRemoval() methods.
-    $updated_config = [];
-    foreach ($call_on_removal as $plugin_type => $plugins) {
-      foreach ($plugins as $plugin_id => $plugin_dependencies) {
-        $removal_successful = $all_plugins[$plugin_id]->onDependencyRemoval($plugin_dependencies);
-        // If the plugin was successfully changed to remove the dependency,
-        // remember the new configuration to later set it. Otherwise, remove the
-        // plugin from the index so the dependency still gets removed.
-        if ($removal_successful) {
-          $updated_config[$plugin_type][$plugin_id] = $all_plugins[$plugin_id]->getConfiguration();
-        }
-        else {
-          unset($all_plugins[$plugin_id]);
-        }
+    foreach ($call_on_removal as $plugin_id => $plugin_dependencies) {
+      $plugin = $all_plugins[$plugin_id];
+      $removal_successful = $plugin->onDependencyRemoval($plugin_dependencies);
+      // If the plugin was successfully changed to remove the dependency,
+      // remember the new configuration to later set it. Otherwise, remove the
+      // plugin from the index so the dependency still gets removed.
+      if ($removal_successful) {
+        $this->notification_settings[$plugin_id] = $plugin->getConfiguration();
+      }
+      else {
+        unset($all_plugins[$plugin_id]);
       }
     }
 
