diff --git a/src/Entity/PathautoPattern.php b/src/Entity/PathautoPattern.php
index 1f894bd..d04e935 100644
--- a/src/Entity/PathautoPattern.php
+++ b/src/Entity/PathautoPattern.php
@@ -6,9 +6,11 @@ use Drupal\Component\Plugin\Exception\ContextException;
 use Drupal\Core\Condition\ConditionPluginCollection;
 use Drupal\Core\Config\Entity\ConfigEntityBase;
 use Drupal\Core\Entity\EntityStorageInterface;
+use Drupal\Core\Entity\EntityWithPluginCollectionInterface;
 use Drupal\Core\Plugin\Context\Context;
 use Drupal\Core\Plugin\ContextAwarePluginInterface;
 use Drupal\Core\Plugin\DefaultSingleLazyPluginCollection;
+use Drupal\node\NodeTypeInterface;
 use Drupal\pathauto\PathautoPatternInterface;
 
 /**
@@ -63,7 +65,7 @@ use Drupal\pathauto\PathautoPatternInterface;
  *   }
  * )
  */
-class PathautoPattern extends ConfigEntityBase implements PathautoPatternInterface {
+class PathautoPattern extends ConfigEntityBase implements PathautoPatternInterface, EntityWithPluginCollectionInterface {
 
   /**
    * The Pathauto pattern ID.
@@ -171,11 +173,7 @@ class PathautoPattern extends ConfigEntityBase implements PathautoPatternInterfa
 
     $this->calculatePluginDependencies($this->getAliasType());
 
-    foreach ($this->getSelectionConditions() as $instance) {
-      $this->calculatePluginDependencies($instance);
-    }
-
-    return $this->getDependencies();
+    return $this;
   }
 
   /**
@@ -333,6 +331,41 @@ class PathautoPattern extends ConfigEntityBase implements PathautoPatternInterfa
   /**
    * {@inheritdoc}
    */
+  public function getPluginCollections() {
+    return [
+      'selection_criteria' => $this->getSelectionConditions(),
+    ];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function onDependencyRemoval(array $dependencies) {
+    $changed = parent::onDependencyRemoval($dependencies);
+
+    $dependencies = array_filter($dependencies);
+    if (!empty($dependencies['config'])) {
+      $selection_conditions = $this->getSelectionConditions();
+      foreach ($dependencies['config'] as $key => $config) {
+        if ($config instanceof NodeTypeInterface) {
+          foreach ($selection_conditions as $uuid => $selection_condition) {
+            if ($selection_condition->getPluginId() === 'node_type') {
+              $configuration = $selection_condition->getConfiguration();
+              unset($configuration['bundles'][$config->id()]);
+              $selection_condition->setConfiguration($configuration);
+              $changed = TRUE;
+            }
+          }
+        }
+      }
+    }
+
+    return $changed;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
   public function applies($object) {
     if ($this->getAliasType()->applies($object)) {
       $definitions = $this->getAliasType()->getContextDefinitions();
