diff --git includes/menu.inc includes/menu.inc
index 9cfad98..3deb5fa 100644
--- includes/menu.inc
+++ includes/menu.inc
@@ -1836,7 +1836,7 @@ function menu_local_tasks($level = 0) {
  * @return
  *   A list of menu router items that are local tasks for the passed in path.
  *
- * @see system_preprocess()
+ * @see contextual_links_preprocess()
  */
 function menu_contextual_links($module, $parent_path, $args) {
   static $path_empty = array();
diff --git misc/contextual_links.css misc/contextual_links.css
deleted file mode 100644
index 7b95153..0000000
--- misc/contextual_links.css
+++ /dev/null
@@ -1,75 +0,0 @@
-/* $Id: contextual_links.css,v 1.2 2009/12/01 13:25:28 dries Exp $ */
-
-/**
- * Contextual links regions.
- */
-.contextual-links-region {
-  outline: none;
-  position: relative;
-}
-.contextual-links-region-active {
-  outline: #999 dashed 1px;
-}
-
-/**
- * Contextual links.
- */
-div.contextual-links-wrapper {
-  display: none;
-  font-size: 90%;
-  position: absolute;
-  right: 5px;
-  top: 0px;
-  z-index: 999;
-}
-html.js div.contextual-links-wrapper {
-  display: block;
-}
-a.contextual-links-trigger {
-  background: transparent url(cog-select.png) no-repeat center center;
-  display: none;
-  height: 20px;
-  margin-top: 2px;
-  outline: none;
-  text-indent: 34px;
-  width: 30px;
-  overflow: hidden;
-}
-a.contextual-links-trigger:hover,
-div.contextual-links-active a.contextual-links-trigger {
-  background-color: #fff;
-}
-div.contextual-links-wrapper ul.contextual-links {
-  display: none;
-  margin: 0;
-  padding: 5px 10px;
-  position: absolute;
-  right: 0;
-  top: 20px;
-  white-space: nowrap;
-}
-.contextual-links-region:hover a.contextual-links-trigger,
-div.contextual-links-active a.contextual-links-trigger,
-div.contextual-links-active ul.contextual-links {
-  display: block;	
-}
-ul.contextual-links li {
-  line-height: 100%;
-  list-style: none;
-  list-style-image: none;
-  margin: 0;
-  padding: 0;
-}
-div.contextual-links-wrapper a {
-  text-decoration: none;
-}
-ul.contextual-links li a {
-  background: #fff;
-  color: #666;
-  display: block;
-  margin: 0.5em 0;
-  padding: 0.3em;
-}
-ul.contextual-links li a:hover {
-  text-decoration: underline;
-}
diff --git misc/contextual_links.js misc/contextual_links.js
deleted file mode 100644
index 252bb23..0000000
--- misc/contextual_links.js
+++ /dev/null
@@ -1,42 +0,0 @@
-// $Id: contextual_links.js,v 1.2 2009/12/01 13:25:28 dries Exp $
-(function ($) {
-
-Drupal.contextualLinks = Drupal.contextualLinks || {};
-
-/**
- * Attach outline behavior for regions associated with contextual links.
- */
-Drupal.behaviors.contextualLinks = {
-  attach: function (context) {
-    $('div.contextual-links-wrapper', context).once('contextual-links', function () {
-      var $wrapper = $(this);
-      var $trigger = $('<a class="contextual-links-trigger" href="#" />').text(Drupal.t('Configure')).click(
-        function () {
-          $wrapper.find('ul.contextual-links').slideToggle(100);
-          $wrapper.toggleClass('contextual-links-active');
-          return false;
-        }
-      );
-      $wrapper.prepend($trigger)
-        .closest('.contextual-links-region').hover(Drupal.contextualLinks.hover, Drupal.contextualLinks.hoverOut);
-    });
-  }
-};
-
-/**
- * Enables outline for the region contextual links are associated with.
- */
-Drupal.contextualLinks.hover = function () {
-  $(this).closest('.contextual-links-region').addClass('contextual-links-region-active');
-};
-
-/**
- * Disables outline for the region contextual links are associated with.
- */
-Drupal.contextualLinks.hoverOut = function () {
-  $(this).closest('.contextual-links-region').removeClass('contextual-links-region-active')
-    .find('.contextual-links-active').removeClass('contextual-links-active')
-    .find('ul.contextual-links').hide();
-};
-
-})(jQuery);
diff --git modules/block/block.tpl.php modules/block/block.tpl.php
index 8243252..ea634d7 100644
--- modules/block/block.tpl.php
+++ modules/block/block.tpl.php
@@ -38,7 +38,7 @@
 ?>
 <div id="block-<?php print $block->module . '-' . $block->delta; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
  
-<?php if ($contextual_links): ?>
+<?php if (!empty($contextual_links)): ?>
   <?php print render($contextual_links); ?>
 <?php endif; ?>
  
diff --git modules/contextual_links/contextual_links.css modules/contextual_links/contextual_links.css
new file mode 100644
index 0000000..7b95153
--- /dev/null
+++ modules/contextual_links/contextual_links.css
@@ -0,0 +1,75 @@
+/* $Id: contextual_links.css,v 1.2 2009/12/01 13:25:28 dries Exp $ */
+
+/**
+ * Contextual links regions.
+ */
+.contextual-links-region {
+  outline: none;
+  position: relative;
+}
+.contextual-links-region-active {
+  outline: #999 dashed 1px;
+}
+
+/**
+ * Contextual links.
+ */
+div.contextual-links-wrapper {
+  display: none;
+  font-size: 90%;
+  position: absolute;
+  right: 5px;
+  top: 0px;
+  z-index: 999;
+}
+html.js div.contextual-links-wrapper {
+  display: block;
+}
+a.contextual-links-trigger {
+  background: transparent url(cog-select.png) no-repeat center center;
+  display: none;
+  height: 20px;
+  margin-top: 2px;
+  outline: none;
+  text-indent: 34px;
+  width: 30px;
+  overflow: hidden;
+}
+a.contextual-links-trigger:hover,
+div.contextual-links-active a.contextual-links-trigger {
+  background-color: #fff;
+}
+div.contextual-links-wrapper ul.contextual-links {
+  display: none;
+  margin: 0;
+  padding: 5px 10px;
+  position: absolute;
+  right: 0;
+  top: 20px;
+  white-space: nowrap;
+}
+.contextual-links-region:hover a.contextual-links-trigger,
+div.contextual-links-active a.contextual-links-trigger,
+div.contextual-links-active ul.contextual-links {
+  display: block;	
+}
+ul.contextual-links li {
+  line-height: 100%;
+  list-style: none;
+  list-style-image: none;
+  margin: 0;
+  padding: 0;
+}
+div.contextual-links-wrapper a {
+  text-decoration: none;
+}
+ul.contextual-links li a {
+  background: #fff;
+  color: #666;
+  display: block;
+  margin: 0.5em 0;
+  padding: 0.3em;
+}
+ul.contextual-links li a:hover {
+  text-decoration: underline;
+}
diff --git modules/contextual_links/contextual_links.info modules/contextual_links/contextual_links.info
new file mode 100644
index 0000000..e842741
--- /dev/null
+++ modules/contextual_links/contextual_links.info
@@ -0,0 +1,7 @@
+; $Id$
+name = Contextual links
+description = Allows to use contextual links to perform actions related to elements on a page.
+package = Core
+version = VERSION
+core = 7.x
+files[] = contextual_links.module
diff --git modules/contextual_links/contextual_links.js modules/contextual_links/contextual_links.js
new file mode 100644
index 0000000..252bb23
--- /dev/null
+++ modules/contextual_links/contextual_links.js
@@ -0,0 +1,42 @@
+// $Id: contextual_links.js,v 1.2 2009/12/01 13:25:28 dries Exp $
+(function ($) {
+
+Drupal.contextualLinks = Drupal.contextualLinks || {};
+
+/**
+ * Attach outline behavior for regions associated with contextual links.
+ */
+Drupal.behaviors.contextualLinks = {
+  attach: function (context) {
+    $('div.contextual-links-wrapper', context).once('contextual-links', function () {
+      var $wrapper = $(this);
+      var $trigger = $('<a class="contextual-links-trigger" href="#" />').text(Drupal.t('Configure')).click(
+        function () {
+          $wrapper.find('ul.contextual-links').slideToggle(100);
+          $wrapper.toggleClass('contextual-links-active');
+          return false;
+        }
+      );
+      $wrapper.prepend($trigger)
+        .closest('.contextual-links-region').hover(Drupal.contextualLinks.hover, Drupal.contextualLinks.hoverOut);
+    });
+  }
+};
+
+/**
+ * Enables outline for the region contextual links are associated with.
+ */
+Drupal.contextualLinks.hover = function () {
+  $(this).closest('.contextual-links-region').addClass('contextual-links-region-active');
+};
+
+/**
+ * Disables outline for the region contextual links are associated with.
+ */
+Drupal.contextualLinks.hoverOut = function () {
+  $(this).closest('.contextual-links-region').removeClass('contextual-links-region-active')
+    .find('.contextual-links-active').removeClass('contextual-links-active')
+    .find('ul.contextual-links').hide();
+};
+
+})(jQuery);
diff --git modules/contextual_links/contextual_links.module modules/contextual_links/contextual_links.module
new file mode 100644
index 0000000..8b3464e
--- /dev/null
+++ modules/contextual_links/contextual_links.module
@@ -0,0 +1,143 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Adds contextual links to perform actions related to elements on a page.
+ */
+
+/**
+ * Implements hook_permission().
+ */
+function contextual_links_permission() {
+  return array(
+    'access contextual links' => array(
+      'title' => t('Use contextual links'),
+      'description' => t('Use contextual links to perform actions related to elements on a page.'),
+    ),
+  );
+}
+
+/**
+ * Implements hook_library().
+ */
+function contextual_links_library() {
+  $path = drupal_get_path('module', 'contextual_links');
+  $libraries['contextual-links'] = array(
+    'title' => 'Contextual links',
+    'website' => 'http://drupal.org/node/473268',
+    'version' => '1.0',
+    'js' => array(
+      $path . '/contextual_links.js' => array(),
+    ),
+    'css' => array(
+      $path . '/contextual_links.css' => array(),
+    ),
+  );
+  return $libraries;
+}
+
+/**
+ * Template variable preprocessor for contextual links.
+ *
+ * @see contextual_links_build_links()
+ */
+function contextual_links_preprocess(&$variables, $hook) {
+  static $hooks;
+
+  // Initialize the $contextual_links template variable.
+  $variables['contextual_links'] = array();
+
+  // Nothing to do here if the user is not permitted to access contextual links.
+  if (!user_access('access contextual links')) {
+    return;
+  }
+
+  if (!isset($hooks)) {
+    $hooks = theme_get_registry();
+  }
+
+  // Determine the primary theme function argument.
+  if (isset($hooks[$hook]['variables'])) {
+    $keys = array_keys($hooks[$hook]['variables']);
+    $key = $keys[0];
+  }
+  else {
+    $key = $hooks[$hook]['render element'];
+  }
+  if (isset($variables[$key])) {
+    $element = $variables[$key];
+  }
+
+  if (isset($element) && is_array($element) && !empty($element['#contextual_links'])) {
+    $variables['contextual_links'] = contextual_links_build_links($element);
+    if (!empty($variables['contextual_links'])) {
+      $variables['classes_array'][] = 'contextual-links-region';
+    }
+  }
+}
+
+/**
+ * Build a renderable array for contextual links.
+ *
+ * @param $element
+ *   A renderable array containing a #contextual_links property, which is a
+ *   keyed array. Each key is the name of the implementing module, and each
+ *   value is an array that forms the function arguments for
+ *   menu_contextual_links(). For example:
+ *   @code
+ *     array('#contextual_links' => array(
+ *       'block' => array('admin/structure/block/manage', array('system', 'navigation')),
+ *       'menu' => array('admin/structure/menu/manage', array('navigation')),
+ *     ))
+ *   @endcode
+ *
+ * @return
+ *   A renderable array representing contextual links.
+ *
+ * @see menu_contextual_links()
+ */
+function contextual_links_build_links($element) {
+  static $destination;
+
+  // Retrieve contextual menu links.
+  $items = array();
+  foreach ($element['#contextual_links'] as $module => $args) {
+    $items += menu_contextual_links($module, $args[0], $args[1]);
+  }
+
+  // Transform contextual links into parameters suitable for theme_link().
+  if (!isset($destination)) {
+    $destination = drupal_get_destination();
+  }
+
+  $links = array();
+  foreach ($items as $class => $item) {
+    $class = drupal_html_class($class);
+    $links[$class] = array(
+      'title' => $item['title'],
+      'href' => $item['href'],
+    );
+    // @todo theme_links() should *really* use the same parameters as l()...
+    if (!isset($item['localized_options']['query'])) {
+      $item['localized_options']['query'] = array();
+    }
+    $item['localized_options']['query'] += $destination;
+    $links[$class] += $item['localized_options'];
+  }
+  $build = array();
+  if ($links) {
+    $build = array(
+      '#prefix' => '<div class="contextual-links-wrapper">',
+      '#suffix' => '</div>',
+      '#theme' => 'links',
+      '#links' => $links,
+      '#attributes' => array('class' => array('contextual-links')),
+      '#attached' => array(
+        'library' => array(array('system', 'contextual-links')),
+      ),
+    );
+  }
+  return $build;
+}
+
diff --git modules/node/node.tpl.php modules/node/node.tpl.php
index 70a4a4d..02c9da1 100644
--- modules/node/node.tpl.php
+++ modules/node/node.tpl.php
@@ -75,7 +75,7 @@
 
   <?php print $user_picture; ?>
 
-  <?php if (!$page && $contextual_links): ?>
+  <?php if (!$page && !empty($contextual_links)): ?>
     <?php print render($contextual_links); ?>
   <?php endif; ?>
 
diff --git modules/system/system.module modules/system/system.module
index 1ba2422..a6669cb 100644
--- modules/system/system.module
+++ modules/system/system.module
@@ -219,10 +219,6 @@ function system_permission() {
     'access administration pages' => array(
       'title' => t('Use the  administration pages and help'),
     ),
-    'access contextual links' => array(
-      'title' => t('Use contextual links'),
-      'description' => t('Use contextual links to perform actions related to elements on a page.'),
-    ),
     'access site in maintenance mode' => array(
       'title' => t('Use the site in maintenance mode'),
     ),
@@ -1076,19 +1072,6 @@ function system_library() {
     ),
   );
 
-  // Contextual links.
-  $libraries['contextual-links'] = array(
-    'title' => 'Contextual links',
-    'website' => 'http://drupal.org/node/473268',
-    'version' => '1.0',
-    'js' => array(
-      'misc/contextual_links.js' => array(),
-    ),
-    'css' => array(
-      'misc/contextual_links.css' => array(),
-    ),
-  );
-
   // Vertical Tabs.
   $libraries['vertical-tabs'] = array(
     'title' => 'Vertical Tabs',
@@ -3551,107 +3534,3 @@ function theme_system_settings_form($variables) {
   return drupal_render_children($variables['form']);
 }
 
-/**
- * Template variable preprocessor for contextual links.
- *
- * @see system_build_contextual_links()
- */
-function system_preprocess(&$variables, $hook) {
-  static $hooks;
-
-  // Initialize the $contextual_links template variable.
-  $variables['contextual_links'] = array();
-
-  // Nothing to do here if the user is not permitted to access contextual links.
-  if (!user_access('access contextual links')) {
-    return;
-  }
-
-  if (!isset($hooks)) {
-    $hooks = theme_get_registry();
-  }
-
-  // Determine the primary theme function argument.
-  if (isset($hooks[$hook]['variables'])) {
-    $keys = array_keys($hooks[$hook]['variables']);
-    $key = $keys[0];
-  }
-  else {
-    $key = $hooks[$hook]['render element'];
-  }
-  if (isset($variables[$key])) {
-    $element = $variables[$key];
-  }
-
-  if (isset($element) && is_array($element) && !empty($element['#contextual_links'])) {
-    $variables['contextual_links'] = system_build_contextual_links($element);
-    if (!empty($variables['contextual_links'])) {
-      $variables['classes_array'][] = 'contextual-links-region';
-    }
-  }
-}
-
-/**
- * Build a renderable array for contextual links.
- *
- * @param $element
- *   A renderable array containing a #contextual_links property, which is a
- *   keyed array. Each key is the name of the implementing module, and each
- *   value is an array that forms the function arguments for
- *   menu_contextual_links(). For example:
- *   @code
- *     array('#contextual_links' => array(
- *       'block' => array('admin/structure/block/manage', array('system', 'navigation')),
- *       'menu' => array('admin/structure/menu/manage', array('navigation')),
- *     ))
- *   @endcode
- *
- * @return
- *   A renderable array representing contextual links.
- *
- * @see menu_contextual_links()
- */
-function system_build_contextual_links($element) {
-  static $destination;
-
-  // Retrieve contextual menu links.
-  $items = array();
-  foreach ($element['#contextual_links'] as $module => $args) {
-    $items += menu_contextual_links($module, $args[0], $args[1]);
-  }
-
-  // Transform contextual links into parameters suitable for theme_link().
-  if (!isset($destination)) {
-    $destination = drupal_get_destination();
-  }
-
-  $links = array();
-  foreach ($items as $class => $item) {
-    $class = drupal_html_class($class);
-    $links[$class] = array(
-      'title' => $item['title'],
-      'href' => $item['href'],
-    );
-    // @todo theme_links() should *really* use the same parameters as l()...
-    if (!isset($item['localized_options']['query'])) {
-      $item['localized_options']['query'] = array();
-    }
-    $item['localized_options']['query'] += $destination;
-    $links[$class] += $item['localized_options'];
-  }
-  $build = array();
-  if ($links) {
-    $build = array(
-      '#prefix' => '<div class="contextual-links-wrapper">',
-      '#suffix' => '</div>',
-      '#theme' => 'links',
-      '#links' => $links,
-      '#attributes' => array('class' => array('contextual-links')),
-      '#attached' => array(
-        'library' => array(array('system', 'contextual-links')),
-      ),
-    );
-  }
-  return $build;
-}
-
diff --git profiles/default/default.info profiles/default/default.info
index 5a67a0a..c862f4b 100644
--- profiles/default/default.info
+++ profiles/default/default.info
@@ -6,6 +6,7 @@ core = 7.x
 dependencies[] = block
 dependencies[] = color
 dependencies[] = comment
+dependencies[] = contextual_links
 dependencies[] = dashboard
 dependencies[] = help
 dependencies[] = image
diff --git themes/garland/block.tpl.php themes/garland/block.tpl.php
index da48010..5546fbb 100644
--- themes/garland/block.tpl.php
+++ themes/garland/block.tpl.php
@@ -3,7 +3,7 @@
 ?>
 <div id="block-<?php print $block->module . '-' . $block->delta; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
 
-<?php if ($contextual_links): ?>
+<?php if (!empty($contextual_links)): ?>
   <?php print render($contextual_links); ?>
 <?php endif; ?>
 
diff --git themes/garland/node.tpl.php themes/garland/node.tpl.php
index 1e0fa6f..d6a8d23 100644
--- themes/garland/node.tpl.php
+++ themes/garland/node.tpl.php
@@ -3,7 +3,7 @@
 ?>
 <div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
 
-  <?php if (!$page && $contextual_links): ?>
+  <?php if (!$page && !empty($contextual_links)): ?>
     <?php print render($contextual_links); ?>
   <?php endif; ?>
 
