 includes/menu.inc                  |   46 +++++++++++++++++++++++++-----------
 modules/dashboard/dashboard.module |   14 +---------
 modules/system/system.module       |    3 +-
 3 files changed, 36 insertions(+), 27 deletions(-)

diff --git includes/menu.inc includes/menu.inc
index a27f590..f9bd635 100644
--- includes/menu.inc
+++ includes/menu.inc
@@ -315,12 +315,16 @@ function menu_get_ancestors($parts) {
     }
     $current = '';
     for ($j = $length; $j >= 0; $j--) {
+      // Check the bit on the $j offset.
       if ($i & (1 << $j)) {
+        // Bit one means the original value.
         $current .= $parts[$length - $j];
       }
       else {
+        // Bit zero means means wildcard.
         $current .= '%';
       }
+      // Unless we are at offset 0, add a slash.
       if ($j) {
         $current .= '/';
       }
@@ -1735,7 +1739,7 @@ function menu_local_tasks($level = 0) {
       return $empty;
     }
 
-    // Get all tabs and the root page.
+    // Get all tabs (also known as local tasks) and the root page.
     $result = db_select('menu_router', NULL, array('fetch' => PDO::FETCH_ASSOC))
       ->fields('menu_router')
       ->condition('tab_root', $router_item['tab_root'])
@@ -1772,12 +1776,19 @@ function menu_local_tasks($level = 0) {
       $tab_count = 0;
       $action_count = 0;
       foreach ($children[$path] as $item) {
+        // Local tasks can be normal items too, so bitmask with 
+        // MENU_IS_LOCAL_TASK before checking.
+        if (!($item['type'] & MENU_IS_LOCAL_TASK)) {
+          // This item is not a tab, skip it.
+          continue;
+        }
         if ($item['access']) {
           $link = $item;
-          // The default task is always active.
-          if ($item['type'] == MENU_DEFAULT_LOCAL_TASK) {
+          // The default task is always active. As tabs can be normal items
+          // too, so bitmask with MENU_DEFAULT_LOCAL_TASK before checking.
+          if (($item['type'] & MENU_DEFAULT_LOCAL_TASK) == MENU_DEFAULT_LOCAL_TASK) {
             // Find the first parent which is not a default local task or action.
-            for ($p = $item['tab_parent']; $tasks[$p]['type'] == MENU_DEFAULT_LOCAL_TASK; $p = $tasks[$p]['tab_parent']);
+            for ($p = $item['tab_parent']; ($tasks[$p]['type'] & MENU_LINKS_TO_PARENT) == MENU_LINKS_TO_PARENT; $p = $tasks[$p]['tab_parent']);
             // Use the path of the parent instead.
             $link['href'] = $tasks[$p]['href'];
             $tabs_current[] = array(
@@ -1789,19 +1800,23 @@ function menu_local_tasks($level = 0) {
             $tab_count++;
           }
           else {
-            if ($item['type'] == MENU_LOCAL_TASK) {
-              $tabs_current[] = array(
-                '#theme' => 'menu_local_task',
+            // Actions can be normal items too, so bitmask with
+            // MENU_LOCAL_ACTION before checking.
+            if (($item['type'] & MENU_LOCAL_ACTION) == MENU_LOCAL_ACTION) {
+              // The item is an action, display it as such.
+              $actions_current[] = array(
+                '#theme' => 'menu_local_action',
                 '#link' => $link,
               );
-              $tab_count++;
+              $action_count++;
             }
             else {
-              $actions_current[] = array(
-                '#theme' => 'menu_local_action',
+              // Else it's a normal tab.
+              $tabs_current[] = array(
+                '#theme' => 'menu_local_task',
                 '#link' => $link,
               );
-              $action_count++;
+              $tab_count++;
             }
           }
         }
@@ -1825,15 +1840,18 @@ function menu_local_tasks($level = 0) {
       $next_parent = '';
       $count = 0;
       foreach ($children[$parent] as $item) {
+        // Skip local actions.
         if ($item['type'] & MENU_IS_LOCAL_ACTION) {
           continue;
         }
         if ($item['access']) {
           $count++;
           $link = $item;
-          if ($item['type'] == MENU_DEFAULT_LOCAL_TASK) {
+          // Local tasks can be normal items too, so bitmask with
+          // MENU_DEFAULT_LOCAL_TASK before checking.
+          if (($item['type'] & MENU_DEFAULT_LOCAL_TASK) == MENU_DEFAULT_LOCAL_TASK) {
             // Find the first parent which is not a default local task.
-            for ($p = $item['tab_parent']; $tasks[$p]['type'] == MENU_DEFAULT_LOCAL_TASK; $p = $tasks[$p]['tab_parent']);
+            for ($p = $item['tab_parent']; ($tasks[$p]['type'] & MENU_DEFAULT_LOCAL_TASK) == MENU_DEFAULT_LOCAL_TASK; $p = $tasks[$p]['tab_parent']);
             // Use the path of the parent instead.
             $link['href'] = $tasks[$p]['href'];
             if ($item['path'] == $router_item['path']) {
@@ -2215,7 +2233,7 @@ function menu_get_active_breadcrumb() {
     $end = end($active_trail);
 
     // Don't show a link to the current page in the breadcrumb trail.
-    if ($item['href'] == $end['href'] || ($item['type'] == MENU_DEFAULT_LOCAL_TASK && $end['href'] != '<front>')) {
+    if ($item['href'] == $end['href'] || (($item['type'] & MENU_DEFAULT_LOCAL_TASK) == MENU_DEFAULT_LOCAL_TASK && $end['href'] != '<front>')) {
       array_pop($breadcrumb);
     }
   }
diff --git modules/dashboard/dashboard.module modules/dashboard/dashboard.module
index 983214a..10e0619 100644
--- modules/dashboard/dashboard.module
+++ modules/dashboard/dashboard.module
@@ -30,9 +30,10 @@ function dashboard_menu() {
     'description' => 'View and customize your dashboard',
     'page callback' => 'dashboard_admin',
     'access arguments' => array('access administration pages'),
+    'type' => MENU_LOCAL_TASK | MENU_NORMAL_ITEM,
     // Make this appear first, so for example, in admin menus, it shows up on
     // the top corner of the window as a convinient "home link".
-    'weight' => -100,
+    'weight' => -15,
   );
   $items['admin/dashboard/customize'] = array(
     'title' => 'Dashboard',
@@ -62,17 +63,6 @@ function dashboard_menu() {
 }
 
 /**
- * Implements hook_menu_alter().
- */
-function dashboard_menu_alter(&$items) {
-  // Make the dashboard the default local task on /admin.
-  $items['admin']['title'] = 'Dashboard';
-  $items['admin']['page callback'] = 'dashboard_admin';
-  $items['admin/dashboard']['type'] = MENU_DEFAULT_LOCAL_TASK;
-  $items['admin/by-task']['type'] = MENU_LOCAL_TASK;
-}
-
-/**
  * Implements hook_block_list_alter().
  *
  * Skip rendering dashboard blocks when not on the dashboard page itself. This
diff --git modules/system/system.module modules/system/system.module
index c3cdb5e..5a6b635 100644
--- modules/system/system.module
+++ modules/system/system.module
@@ -543,13 +543,14 @@ function system_menu() {
     'access arguments' => array('access administration pages'),
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'file' => 'system.admin.inc',
+    'weight' => -20,
   );
   $items['admin/by-module'] = array(
     'title' => 'By module',
     'page callback' => 'system_admin_by_module',
     'access arguments' => array('access administration pages'),
     'type' => MENU_LOCAL_TASK,
-    'weight' => 2,
+    'weight' => -18,
     'file' => 'system.admin.inc',
   );
 
