diff --git a/includes/module.inc b/includes/module.inc
index 10996eb655a267fffad7273ef8e7e4e75e691200..ec0f83a6b1e0583c99b995fe32539ae1880ca687 100644
--- a/includes/module.inc
+++ b/includes/module.inc
@@ -369,6 +369,8 @@ function module_enable($module_list, $enable_dependencies = TRUE) {
       registry_update();
       // Refresh the schema to include it.
       drupal_get_schema(NULL, TRUE);
+      // Clear entity cache.
+      entity_info_cache_clear();
 
       // Now install the module if necessary.
       if (drupal_get_installed_schema_version($module, TRUE) == SCHEMA_UNINSTALLED) {
diff --git a/modules/overlay/overlay-child.js b/modules/overlay/overlay-child.js
index 0184455173474b33a5cb3c716cd4879f831771e2..7570ec6130b07d572298f91bf28f63825766b62a 100644
--- a/modules/overlay/overlay-child.js
+++ b/modules/overlay/overlay-child.js
@@ -31,8 +31,8 @@ Drupal.behaviors.overlayChild = {
     // may have decided to tell us the parent window to close the popup dialog.
     if (settings.closeOverlay) {
       parent.Drupal.overlay.bindChild(window, true);
-      // Close the child window from a separate thread because the current
-      // one is busy processing Drupal behaviors.
+      // Use setTimeout to close the child window from a separate thread,
+      // because the current one is busy processing Drupal behaviors.
       setTimeout(function () {
         // We need to store the parent variable locally because it will
         // disappear as soon as we close the iframe.
diff --git a/modules/overlay/overlay-parent.js b/modules/overlay/overlay-parent.js
index 2ed3914cf5a77370cdb67bb9c8ba22e76836443d..d362a945d71b1ae340140fa7c8cc55bc5b39403f 100644
--- a/modules/overlay/overlay-parent.js
+++ b/modules/overlay/overlay-parent.js
@@ -517,7 +517,7 @@ Drupal.overlay.bindChild = function (iframeWindow, isClosing) {
       if (!$target.size()) {
         $target = self.$iframeDocument;
       }
-      setTimeout(function () { $target.focus(); }, 10);
+      $target.focus();
       return false;
     }
   });
@@ -528,16 +528,16 @@ Drupal.overlay.bindChild = function (iframeWindow, isClosing) {
     if (event.keyCode) {
       if (event.keyCode == $.ui.keyCode.TAB) {
         if (event.shiftKey && event.target == $firstTabbable.get(0)) {
-          setTimeout(function () { $closeButton.focus(); }, 10);
+          $closeButton.focus();
           return false;
         }
         else if (!event.shiftKey && event.target == $lastTabbable.get(0)) {
-          setTimeout(function () { $closeButton.focus(); }, 10);
+          $closeButton.focus();
           return false;
         }
       }
       else if (event.keyCode == $.ui.keyCode.ESCAPE) {
-        setTimeout(function () { self.close(); }, 10);
+        self.close();
         return false;
       }
     }
@@ -548,11 +548,9 @@ Drupal.overlay.bindChild = function (iframeWindow, isClosing) {
   // close button of the dialog (default).
   $(document).bind('keydown.overlay-event', function (event) {
     if (event.keyCode && event.keyCode == $.ui.keyCode.TAB) {
-      setTimeout(function () {
-        if (!self.$iframeWindow(':tabbable:not(form):first').focus().size()) {
+      if (!self.$iframeWindow(':tabbable:not(form):first').focus().size()) {
           $closeButton.focus();
-        }
-      }, 10);
+      }
       return false;
     }
   });
diff --git a/modules/system/system.test b/modules/system/system.test
index 6fb15a7362d448421114621b3978db4cd5a8841e..e20fd769e1547b2bfd7fdffb72f4f212cc2c2f34 100644
--- a/modules/system/system.test
+++ b/modules/system/system.test
@@ -157,6 +157,16 @@ class EnableDisableTestCase extends ModuleTestCase {
     $this->drupalPost('admin/modules', $edit, t('Save configuration'));
     $this->assertText(t('The configuration options have been saved.'), t('Modules status has been updated.'));
   }
+
+  /**
+   * Tests entity cache after enabling a module with a dependency on an enitity
+   * providing module.
+   */
+  function testEntityCache() {
+    module_enable(array('entity_cache_test'));
+    $info = variable_get('entity_cache_test');
+    $this->assertNotNull($info, t('Entity information must not be NULL'));
+  }
 }
 
 /**