diff --git a/modules/toolbar/toolbar.module b/modules/toolbar/toolbar.module
index 6d1b581..a0b0747 100644
--- a/modules/toolbar/toolbar.module
+++ b/modules/toolbar/toolbar.module
@@ -296,10 +296,10 @@ function toolbar_get_menu_tree() {
 }
 
 /**
- * Generates a links array from a menu tree array.
+ * Generates an array of links from a menu tree array.
  *
- * Based on menu_navigation_links(). Adds path based IDs and icon placeholders
- * to the links.
+ * Based on menu_navigation_links(). It adds path based CSS classes for the
+ * menu items, icon placeholders and overlay classes for the links.
  *
  * @return
  *   An array of links as defined above.
@@ -308,27 +308,34 @@ function toolbar_menu_navigation_links($tree) {
   $links = array();
   foreach ($tree as $item) {
     if (!$item['link']['hidden'] && $item['link']['access']) {
-      // Make sure we have a path specific ID in place, so we can attach icons
-      // and behaviors to the items.
-      $id = str_replace(array('/', '<', '>'), array('-', '', ''), $item['link']['href']);
-
       $link = $item['link']['localized_options'];
       $link['href'] = $item['link']['href'];
       // Add icon placeholder.
       $link['title'] = '<span class="icon"></span>' . check_plain($item['link']['title']);
-      // Add admin link ID.
-      $link['attributes'] = array('id' => 'toolbar-link-' . $id);
+      // Add to-overlay class for the overlay.
+      $link['attributes']['class'][] = 'to-overlay';
       if (!empty($item['link']['description'])) {
         $link['title'] .= ' <span class="element-invisible">(' . $item['link']['description'] . ')</span>';
         $link['attributes']['title'] = $item['link']['description'];
       }
       $link['html'] = TRUE;
 
-      $class = ' path-' . $id;
+      // The querystring of the link is also used to build the path based
+      // CSS class, to be able to theme items pointing to the same path but
+      // with different GET parameters.
+      $full_href = $item['link']['href'] . (isset($item['link']['options']['query']) ? '?' . $item['link']['options']['query'] : '');
+      // Clean up the link destination to prepare a path based CSS class.
+      $class = strtolower(preg_replace('/[^a-z0-9-_]+/i', '-', strtolower($full_href)));
+      $class = trim(preg_replace('/--+/', '-', $class, '-'));
+      // Prefix the path based CSS class.
+      $class = 'path-' . $class;
       if (toolbar_in_active_trail($item['link']['href'])) {
         $class .= ' active-trail';
       }
-      $links['menu-' . $item['link']['mlid'] . $class] = $link;
+
+      // The keys of the array will be used for list item as classes
+      // by theme_links().
+      $links['menu-' . $item['link']['mlid'] . ' ' . $class] = $link;
     }
   }
   return $links;
