diff --git a/includes/rules.core.inc b/includes/rules.core.inc
index a274217..6b30651 100644
--- a/includes/rules.core.inc
+++ b/includes/rules.core.inc
@@ -915,16 +915,21 @@ abstract class RulesPlugin extends RulesExtendable {
       return $this->parent->save($name, $module);
     }
     else {
-      // In case the config is not dirty, pre-calculate the dependencies for
-      // later checking. Note that this also triggers processing settings if
-      // necessary.
-      // @see rules_modules_enabled()
+      // Update the dirty flag before saving.
       // However, this operation depends on a fully built Rules-cache, so skip
       // it when entities in code are imported to the database.
       // @see _rules_rebuild_cache()
-      if (empty($this->dirty) && empty($this->is_rebuild)) {
-        $this->dependencies = $this->dependencies();
+      if (empty($this->is_rebuild)) {
+        rules_config_update_dirty_flag($this, FALSE);
+        // In case the config is not dirty, pre-calculate the dependencies for
+        // later checking. Note that this also triggers processing settings if
+        // necessary.
+        // @see rules_modules_enabled()
+        if (empty($this->dirty)) {
+          $this->dependencies = $this->dependencies();
+        }
       }
+
       $this->plugin = $this->itemName;
       $this->name = isset($name) ? $name : $this->name;
       $this->module = !isset($this->module) || $module != 'rules' ? $module : $this->module;
@@ -1229,11 +1234,11 @@ abstract class RulesPlugin extends RulesExtendable {
     parent::rebuildCache($itemInfo, $cache);
     if (!empty($this->itemInfo['component'])) {
       // Just move each component into the cache.
-      $components = rules_config_load_multiple(FALSE, array('plugin' => $this->itemName, 'dirty' => 0));
+      $components = rules_config_load_multiple(FALSE, array('plugin' => $this->itemName));
 
       foreach ($components as $id => $component) {
-        try {
-          $component->integrityCheck();
+        rules_config_update_dirty_flag($component);
+        if (!$component->dirty) {
           // Clone the component to avoid modules getting the to be cached
           // version from the static loading cache.
           $component = clone $component;
@@ -1242,16 +1247,6 @@ abstract class RulesPlugin extends RulesExtendable {
           drupal_alter('rules_component', $this->itemName, $component);
           rules_set_cache('comp_' . $component->name, $component);
         }
-        catch (RulesIntegrityException $e) {
-          // Mark the component as dirty and do not cache it.
-          $component->dirty = TRUE;
-          db_update('rules_config')
-            ->fields(array('dirty' => 1))
-            ->condition('id', $component->id)
-            ->execute();
-          $variables = array('%component' => $component->label(), '%name' => $component->name, '!message' => $e->getMessage());
-          watchdog('rules', 'The component %component (%name) fails the integrity check and cannot be executed. Error: !message', $variables, WATCHDOG_ERROR);
-        }
       }
     }
   }
diff --git a/includes/rules.plugins.inc b/includes/rules.plugins.inc
index 31e93a8..539504a 100644
--- a/includes/rules.plugins.inc
+++ b/includes/rules.plugins.inc
@@ -693,26 +693,16 @@ class RulesEventSet extends RulesRuleSet {
         'variables' => isset($info['arguments']) ? $info['arguments'] : array(),
       );
       // Add all rules associated with this event to an EventSet for caching.
-      if ($rules = rules_config_load_multiple(FALSE, array('event' => $name, 'active' => TRUE, 'dirty' => 0))) {
+      if ($rules = rules_config_load_multiple(FALSE, array('event' => $name, 'active' => TRUE))) {
         $event = new RulesEventSet($info);
         $event->name = $name;
         foreach ($rules as $rule) {
-          try {
-            $rule->integrityCheck();
+          rules_config_update_dirty_flag($rule);
+          if (!$rule->dirty) {
             // Clone the rule to avoid modules getting the changed version from
             // the static cache.
             $event->rule(clone $rule);
           }
-          catch (RulesIntegrityException $e) {
-            // Mark the rule as dirty and do not cache it.
-            $rule->dirty = TRUE;
-            db_update('rules_config')
-              ->fields(array('dirty' => 1))
-              ->condition('id', $rule->id)
-              ->execute();
-            $variables = array('%rule' => $rule->label(), '%name' => $rule->name, '!message' => $e->getMessage());
-            watchdog('rules', 'The rule %rule (%name) fails the integrity check and cannot be executed. Error: !message', $variables, WATCHDOG_ERROR);
-          }
         }
         if ($event->children) {
           $event->sortChildren();
diff --git a/rules.module b/rules.module
index 8111b29..45f24ff 100644
--- a/rules.module
+++ b/rules.module
@@ -686,6 +686,38 @@ function rules_config_delete(array $ids) {
 }
 
 /**
+ * Ensures the configuration's 'dirty' flag is up to date.
+ *
+ * @param $update
+ *   Whether the dirty flag is also updated in the database if necessary.
+ */
+function rules_config_update_dirty_flag($rules_config, $update = TRUE) {
+  $was_dirty = !empty($rules_config->dirty);
+  try {
+    $rules_config->integrityCheck();
+    $rules_config->dirty = FALSE;
+    if ($was_dirty) {
+      $variables = array('%label' => $rules_config->label(), '%name' => $rules_config->name, '@plugin' => $rules_config->plugin());
+      watchdog('rules', 'The @plugin %label (%name) passes the integrity check and is going to be executed again.', $variables, WATCHDOG_INFO);
+    }
+  }
+  catch (RulesIntegrityException $e) {
+    $rules_config->dirty = TRUE;
+    if (!$was_dirty) {
+      $variables = array('%label' => $rules_config->label(), '%name' => $rules_config->name, '!message' => $e->getMessage(), '@plugin' => $rules_config->plugin());
+      watchdog('rules', 'The @plugin %label (%name) fails the integrity check and cannot be executed. Error: !message', $variables, WATCHDOG_ERROR);
+    }
+  }
+  // Save the updated dirty flag to the database.
+  if ($was_dirty != $rules_config->dirty) {
+    db_update('rules_config')
+      ->fields(array('dirty' => (int) $rules_config->dirty))
+      ->condition('id', $rules_config->id)
+      ->execute();
+  }
+}
+
+/**
  * Invokes a hook and the associated rules event.
  *
  * Calling this function does the same as calling module_invoke_all() and
