diff --git a/core/misc/tableheader.js b/core/misc/tableheader.js
index 225cb73..42a3de7 100644
--- a/core/misc/tableheader.js
+++ b/core/misc/tableheader.js
@@ -1,4 +1,4 @@
-(function ($) {
+(function ($, Drupal) {
 
 "use strict";
 
@@ -6,25 +6,90 @@
  * Attaches sticky table headers.
  */
 Drupal.behaviors.tableHeader = {
-  attach: function (context, settings) {
+  init: false,
+  attach: function (context) {
     if (!$.support.fixedPosition) {
       return;
     }
-
-    $(context).find('table.sticky-enabled').once('tableheader', function () {
-      $(this).data("drupal-tableheader", new Drupal.tableHeader(this));
-    });
+    $(window).one('scroll.TableHeaderInit', $.proxy(tableHeaderInitHandler, context));
   }
 };
 
+function scroll(position) {
+  return document.documentElement[position] || document.body[position];
+}
+
+// Select and initilize sticky table headers.
+function tableHeaderInitHandler() {
+  var $tables = $(this).find('table.sticky-enabled').once('tableheader');
+  for (var i = 0, il = $tables.length; i < il; i += 1) {
+    TableHeader.tables.push(new TableHeader($tables[i]));
+  }
+}
+
+// Helper method to loop through tables and execute a method.
+function forTables(method, arg) {
+  var tables = TableHeader.tables;
+  for (var i = 0, il = tables.length; i < il; i += 1) {
+    tables[i][method](arg);
+  }
+}
+
+function tableHeaderReizeHandler(e) {
+  forTables('recalculateSticky');
+}
+
+function tableHeaderOnScrollHandler(e) {
+  forTables('onScroll');
+}
+
+function tableHeaderOffsetChangeHandler(e) {
+  // Compute the new offset value.
+  TableHeader.computeOffsetTop();
+  forTables('stickyPosition', TableHeader.offsetTop);
+}
+
+// Bind event that need to change all tables.
+$(window).on({
+  /**
+   * When resizing table width and offset top can change, recalculate everything.
+   */
+  'resize.TableHeader': tableHeaderReizeHandler,
+
+  /**
+   * Bind only one event to take care of calling all scroll callbacks.
+   */
+  'scroll.TableHeader': tableHeaderOnScrollHandler
+});
+// Bind to custom Drupal events.
+$(document).on({
+  /**
+   * Recalculate columns width when window is resized and when show/hide
+   * weight is triggered.
+   */
+  'columnschange.TableHeader': tableHeaderReizeHandler,
+
+  /**
+   * Offset value vas changed by a third party script.
+   */
+  'offsettopchange.TableHeader': tableHeaderOffsetChangeHandler
+});
+
 /**
  * Constructor for the tableHeader object. Provides sticky table headers.
  *
+ * TableHeader will make the current table header stick to the top of the page
+ * if the table is very long.
+ *
+ * Fire a custom "topoffsetchange" event to make TableHeader compute the
+ * new offset value from the "data-offset-top" attributes of relevant elements.
+ *
  * @param table
  *   DOM object for the table to add a sticky header to.
+ *
+ * @constructor
  */
-Drupal.tableHeader = function (table) {
-  var self = this;
+function TableHeader(table) {
   var $table = $(table);
 
   this.originalTable = $table;
@@ -32,80 +97,165 @@ Drupal.tableHeader = function (table) {
   this.originalHeaderCells = this.originalHeader.find('> tr > th');
   this.displayWeight = null;
 
-  // React to columns change to avoid making checks in the scroll callback.
-  this.originalTable.bind('columnschange', function (e, display) {
-    // This will force header size to be calculated on scroll.
-    self.widthCalculated = (self.displayWeight !== null && self.displayWeight === display);
-    self.displayWeight = display;
-  });
-
-  // Clone the table header so it inherits original jQuery properties. Hide
-  // the table to avoid a flash of the header clone upon page load.
-  this.stickyTable = $('<table class="sticky-header"/>')
-    .insertBefore(this.originalTable)
-    .css({ position: 'fixed', top: '0px' });
-  this.stickyHeader = this.originalHeader.clone(true)
-    .hide()
-    .appendTo(this.stickyTable);
-  this.stickyHeaderCells = this.stickyHeader.find('> tr > th');
-
   this.originalTable.addClass('sticky-table');
-  $(window)
-    .bind('scroll.drupal-tableheader', $.proxy(this, 'eventhandlerRecalculateStickyHeader'))
-    .bind('resize.drupal-tableheader', { calculateWidth: true }, $.proxy(this, 'eventhandlerRecalculateStickyHeader'))
-    // Make sure the anchor being scrolled into view is not hidden beneath the
-    // sticky table header. Adjust the scrollTop if it does.
-    .bind('drupalDisplaceAnchor.drupal-tableheader', function () {
-      window.scrollBy(0, -self.stickyTable.outerHeight());
-    })
-    // Make sure the element being focused is not hidden beneath the sticky
-    // table header. Adjust the scrollTop if it does.
-    .bind('drupalDisplaceFocus.drupal-tableheader', function (event) {
-      if (self.stickyVisible && event.clientY < (self.stickyOffsetTop + self.stickyTable.outerHeight()) && event.$target.closest('sticky-header').length === 0) {
-        window.scrollBy(0, -self.stickyTable.outerHeight());
-      }
-    })
-    .triggerHandler('resize.drupal-tableheader');
+  this.tableHeight = $table[0].clientHeight;
+  this.tableOffset = this.originalTable.offset();
 
-  // We hid the header to avoid it showing up erroneously on page load;
-  // we need to unhide it now so that it will show up when expected.
-  this.stickyHeader.show();
-};
+  // React to columns change to avoid making checks in the scroll callback.
+  this.originalTable.bind('columnschange', $.proxy(function (e, display) {
+    if (this.displayWeight === null || this.displayWeight !== display) {
+      this.recalculateSticky();
+    }
+    this.displayWeight = display;
+  }, this));
+
+  // Create and display sticky header.
+  this.createSticky();
+}
 
 /**
- * Event handler: recalculates position of the sticky table header.
- *
- * @param event
- *   Event being triggered.
+ * Store the state of TableHeader.
  */
-Drupal.tableHeader.prototype.eventhandlerRecalculateStickyHeader = function (event) {
-  var self = this;
-  var calculateWidth = event.data && event.data.calculateWidth;
-
-  // Reset top position of sticky table headers to the current top offset.
-  this.stickyOffsetTop = Drupal.settings.tableHeaderOffset ? eval(Drupal.settings.tableHeaderOffset + '()') : 0;
-  this.stickyTable.css('top', this.stickyOffsetTop + 'px');
-
-  // Save positioning data.
-  var viewHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
-  if (calculateWidth || this.viewHeight !== viewHeight) {
-    this.viewHeight = viewHeight;
-    this.vPosition = this.originalTable.offset().top - 4 - this.stickyOffsetTop;
-    this.hPosition = this.originalTable.offset().left;
-    this.vLength = this.originalTable[0].clientHeight - 100;
-    calculateWidth = true;
+$.extend(TableHeader, {
+  /**
+   * This will store the state of all processed tables.
+   *
+   * @type {Array}
+   */
+  tables: [],
+
+  /**
+   * Cache of computed offset value.
+   *
+   * @type {Number}
+   */
+  offsetTop: 0,
+
+  /**
+   * Sum all [data-offset-top] values and cache it.
+   */
+  computeOffsetTop: function () {
+    var $offsets = $('[data-offset-top]');
+    var value, sum = 0;
+    for (var i = 0, il = $offsets.length; i < il; i += 1) {
+      value = parseInt($offsets[i].getAttribute('data-offset-top'), 10);
+      sum += !isNaN(value) ? value : 0;
+    }
+    this.offsetTop = sum;
+    return sum;
   }
+});
+
+/**
+ * Extend TableHeader prototype.
+ */
+$.extend(TableHeader.prototype, {
+  /**
+   * Minimum height in pixels for the table to have a sticky header.
+   */
+  minHeight: 100,
 
-  // Track horizontal positioning relative to the viewport and set visibility.
-  var hScroll = document.documentElement.scrollLeft || document.body.scrollLeft;
-  var vOffset = (document.documentElement.scrollTop || document.body.scrollTop) - this.vPosition;
-  this.stickyVisible = vOffset > 0 && vOffset < this.vLength;
-  this.stickyTable.css({ left: (-hScroll + this.hPosition) + 'px', visibility: this.stickyVisible ? 'visible' : 'hidden' });
+  /**
+   * Absolute position of the table on the page.
+   */
+  tableOffset: null,
 
-  // Only perform expensive calculations if the sticky header is actually
-  // visible or when forced.
-  if (this.stickyVisible && (calculateWidth || !this.widthCalculated)) {
-    this.widthCalculated = true;
+  /**
+   * Absolute position of the table on the page.
+   */
+  tableHeight: null,
+
+  /**
+   * Boolean storing the sticky header visibility state.
+   */
+  stickyVisible: false,
+
+  /**
+   * Create the duplicate header.
+   */
+  createSticky: function () {
+    // Clone the table header so it inherits original jQuery properties.
+    var $stickyHeader = this.originalHeader.clone(true);
+    // Hide the table to avoid a flash of the header clone upon page load.
+    this.stickyTable = $('<table class="sticky-header"/>')
+      .css({
+        visibility: 'hidden',
+        position: 'fixed',
+        top: '0px'
+      })
+      .append($stickyHeader)
+      .insertBefore(this.originalTable);
+
+    this.stickyHeaderCells = $stickyHeader.find('> tr > th');
+
+    // Initialize all computations.
+    this.recalculateSticky();
+  },
+
+  /**
+   * Set absolute position of sticky.
+   *
+   * @param top
+   * @param left
+   */
+  stickyPosition: function (offsetTop, offsetLeft) {
+    var css = {};
+    if (!isNaN(offsetTop)) {
+      css.top = offsetTop + 'px';
+    }
+    if (!isNaN(offsetLeft)) {
+      css.left = (this.tableOffset.left - offsetLeft) + 'px';
+    }
+    return this.stickyTable.css(css);
+  },
+
+  /**
+   * Returns true if sticky is currently visible.
+   */
+  checkStickyVisible: function () {
+    var scrollTop = scroll('scrollTop');
+    var tableTop = this.tableOffset.top - TableHeader.offsetTop;
+    var tableBottom = tableTop + this.tableHeight;
+    var visible = false;
+
+    if (tableTop < scrollTop && scrollTop < (tableBottom - this.minHeight)) {
+      visible = true;
+    }
+
+    this.stickyVisible = visible;
+    return visible;
+  },
+
+  /**
+   * Check if sticky header should be displayed.
+   *
+   * This function is throttled to once every 250ms to avoid unnecessary calls.
+   *
+   * @param event
+   */
+  onScroll: function (e) {
+    this.checkStickyVisible();
+    // don't trigger a css change if there is no need.
+    if (scroll('scrollLeft') !== 0) {
+      // Track horizontal positioning relative to the viewport.
+      this.stickyPosition(null, scroll('scrollLeft'));
+    }
+    this.stickyTable.css('visibility', this.stickyVisible ? 'visible' : 'hidden');
+  },
+
+  /**
+   * Event handler: recalculates position of the sticky table header.
+   *
+   * @param event
+   *   Event being triggered.
+   */
+  recalculateSticky: function (event) {
+    // Update offset top.
+    TableHeader.computeOffsetTop();
+    this.tableOffset = this.originalTable.offset();
+    this.stickyPosition(TableHeader.offsetTop);
+
+    // Update columns width.
     var $that = null;
     var $stickyCell = null;
     var display = null;
@@ -123,8 +273,11 @@ Drupal.tableHeader.prototype.eventhandlerRecalculateStickyHeader = function (eve
         $stickyCell.css('display', 'none');
       }
     }
-    this.stickyTable.css('width', this.originalTable.css('width'));
+    this.stickyTable.css('width', this.originalTable.outerWidth());
   }
-};
+});
+
+// Expose constructor in the public space.
+Drupal.TableHeader = TableHeader;
 
-})(jQuery);
+}(jQuery, Drupal));
diff --git a/core/modules/toolbar/toolbar.js b/core/modules/toolbar/toolbar.js
index ee8bddb..26bfd46 100644
--- a/core/modules/toolbar/toolbar.js
+++ b/core/modules/toolbar/toolbar.js
@@ -8,18 +8,23 @@ Drupal.toolbar = Drupal.toolbar || {};
  * Attach toggling behavior and notify the overlay of the toolbar.
  */
 Drupal.behaviors.toolbar = {
-  attach: function(context) {
-    var $context = $(context);
-    // Set the initial state of the toolbar.
-    $context.find('#toolbar').once('toolbar', Drupal.toolbar.init);
+  attach: function(context, settings) {
+    var $toolbar = $('#toolbar').once('toolbar');
+    if ($toolbar.length) {
 
-    // Toggling toolbar drawer.
-    $context.find('#toolbar a.toggle').once('toolbar-toggle').click(function(e) {
-      Drupal.toolbar.toggle();
-      // Allow resize event handlers to recalculate sizes/positions.
-      $(window).triggerHandler('resize');
-      return false;
-    });
+      // Set the initial state of the toolbar.
+      Drupal.toolbar.init();
+
+      $(window).on('resize.toolbar', Drupal.toolbar.height);
+
+      // Toggling toolbar drawer.
+      $toolbar.find('a.toggle').once('toolbar-toggle').click(function(e) {
+        e.preventDefault();
+        Drupal.toolbar.toggle();
+        // Allow resize event handlers to recalculate sizes/positions.
+        $(window).triggerHandler('resize');
+      });
+    }
   }
 };
 
@@ -96,6 +101,7 @@ Drupal.toolbar.toggle = function() {
 };
 
 Drupal.toolbar.height = function() {
+  // @TODO this needs to be cached outside this function.
   var $toolbar = $('#toolbar');
   var height = $toolbar.outerHeight();
   // In modern browsers (including IE9), when box-shadow is defined, use the
@@ -107,6 +113,7 @@ Drupal.toolbar.height = function() {
   if (!boxShadow && /DXImageTransform\.Microsoft\.Shadow/.test($toolbar.css('filter'))) {
     height -= $toolbar[0].filters.item("DXImageTransform.Microsoft.Shadow").strength;
   }
+  $toolbar.attr('data-offset-top', height);
   return height;
 };
 
diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module
index 904a2f8..931ad52 100644
--- a/core/modules/toolbar/toolbar.module
+++ b/core/modules/toolbar/toolbar.module
@@ -194,10 +194,6 @@ function toolbar_view() {
     '#attached'=> array(
       'js' => array(
         $module_path . '/toolbar.js',
-        array(
-          'data' => array('tableHeaderOffset' => 'Drupal.toolbar.height'),
-          'type' => 'setting'
-        ),
       ),
       'css' => array(
         $module_path . '/toolbar.css',
