diff --git a/core/includes/common.inc b/core/includes/common.inc
index 4229d52..3d77647 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -7273,10 +7277,27 @@ function drupal_implode_tags($tags) {
  * invokes a hook so that other modules' cache data can be cleared as well.
  */
 function drupal_flush_all_caches() {
-  // Change query-strings on css/js files to enforce reload for all users.
-  _drupal_flush_css_js();
+  // Ensure that all following rebuilds can rely on fresh entity information
+  // by resetting all static caches.
+  drupal_static_reset();
 
+  // Rebuild class registry and module information.
   registry_rebuild();
+
+  // Clear core cache tables. This is required to come first, so all following
+  // operations are not able to invoke API functions that reload stale
+  // information from the database cache (which in turn might be cached in a
+  // static variable).
+  // Don't clear cache_form - in-progress form submissions may break.
+  // Page cache is cleared separately below, after most rebuilds (especially
+  // menu rebuild) have been done.
+  foreach (array('cache', 'path', 'bootstrap') as $bin) {
+    cache($bin)->flush();
+  }
+
+  // Change query-strings on css/js files to enforce reload for all users.
+  _drupal_flush_css_js();
+  // CSS and JS caches may rely on custom module-provided stream wrappers.
   drupal_clear_css_cache();
   drupal_clear_js_cache();
 
@@ -7285,22 +7306,34 @@ function drupal_flush_all_caches() {
   system_rebuild_theme_data();
   drupal_theme_rebuild();
 
+  // Rebuilding node types requires fresh entity information, since node_menu()
+  // defines router items based on node types, so they need to be rebuilt before
+  // hook_menu() is invoked.
+  // @todo Replace with a hook_rebuild(); contributed modules potentially also
+  //   need to rebuild data before hook_menu() is invoked. Rebuilding logic
+  //   should not be contained in hook_menu(), since these are separate
+  //   operations, and menu_rebuild() might not invoke hook_menu() at all due to
+  //   the locking framework.
   node_types_rebuild();
-  // node_menu() defines menu items based on node types so it needs to come
-  // after node types are rebuilt.
+
+  // Rebuild the menu router. Many hook_menu() implementations register router
+  // items based on entity information.
   menu_rebuild();
 
   // Synchronize to catch any actions that were added or removed.
   actions_synchronize();
 
-  // Don't clear cache_form - in-progress form submissions may break.
-  // Ordered so clearing the page cache will always be the last action.
-  $core = array('cache', 'path', 'filter', 'bootstrap', 'page');
-  $cache_bins = array_merge(module_invoke_all('flush_caches'), $core);
-  foreach ($cache_bins as $bin) {
+  // Clear module caches. Some implementations of hook_flush_caches() are not
+  // only returning cache tables to flush, but additionally attempt to rebuild
+  // module data, which may rely on various core registries and caches.
+  // Therefore, invoke these last, after flushing and rebuilding core data.
+  foreach (module_invoke_all('flush_caches') as $bin) {
     cache($bin)->flush();
   }
 
+  // Clear the page cache after all cache flushes and rebuilds.
+  cache('page')->flush();
+
   // Rebuild the bootstrap module list. We do this here so that developers
   // can get new hook_boot() implementations registered without having to
   // write a hook_update_N() function.
diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index 2ad725a..f25a470 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -772,6 +772,13 @@ function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE)
 }
 
 /**
+ * Implements hook_flush_caches().
+ */
+function filter_flush_caches() {
+  return array('filter');
+}
+
+/**
  * Expands an element into a base element with text format selector attached.
  *
  * The form element will be expanded into two separate form elements, one
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index 0c3cfb7..a5ba0ab 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -1953,9 +1953,6 @@ function node_menu() {
     'type' => MENU_CALLBACK,
   );
   // @todo Remove this loop when we have a 'description callback' property.
-  // Reset internal static cache of _node_types_build(), forces to rebuild the
-  // node type information.
-  node_type_cache_reset();
   foreach (node_type_get_types() as $type) {
     $type_url_str = str_replace('_', '-', $type->type);
     $items['node/add/' . $type_url_str] = array(
