diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 3c4576a..7076fbd 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1782,97 +1782,17 @@ function theme_breadcrumb($variables) {
 }
 
 /**
- * Returns HTML for a table.
  *
- * @param $variables
- *   An associative array containing:
- *   - header: An array containing the table headers. Each element of the array
- *     can be either a localized string or an associative array with the
- *     following keys:
- *     - "data": The localized title of the table column.
- *     - "field": The database field represented in the table column (required
- *       if user is to be able to sort on this column).
- *     - "sort": A default sort order for this column ("asc" or "desc").
- *     - "class": An array of values for the 'class' attribute. In particular,
- *        the least important columns that can be hidden on narrow and medium
- *        width screens should have a 'priority-low' class, referenced with the
- *        RESPONSIVE_PRIORITY_LOW constant. Columns that should be shown on
- *        medium+ wide screens should be marked up with a class of
- *        'priority-medium', referenced by with the RESPONSIVE_PRIORITY_MEDIUM
- *        constant. Themes may hide columns with one of these two classes on
- *        narrow viewports to save horizontal space.
- *     - Any HTML attributes, such as "colspan", to apply to the column header
- *       cell.
- *   - rows: An array of table rows. Every row is an array of cells, or an
- *     associative array with the following keys:
- *     - "data": an array of cells
- *     - Any HTML attributes, such as "class", to apply to the table row.
- *     - "no_striping": a boolean indicating that the row should receive no
- *       'even / odd' styling. Defaults to FALSE.
- *     Each cell can be either a string or an associative array with the
- *     following keys:
- *     - "data": The string to display in the table cell.
- *     - "header": Indicates this cell is a header.
- *     - Any HTML attributes, such as "colspan", to apply to the table cell.
- *     Here's an example for $rows:
- *     @code
- *     $rows = array(
- *       // Simple row
- *       array(
- *         'Cell 1', 'Cell 2', 'Cell 3'
- *       ),
- *       // Row with attributes on the row and some of its cells.
- *       array(
- *         'data' => array('Cell 1', array('data' => 'Cell 2', 'colspan' => 2)), 'class' => array('funky')
- *       )
- *     );
- *     @endcode
- *   - attributes: An array of HTML attributes to apply to the table tag.
- *   - caption: A localized string to use for the <caption> tag.
- *   - colgroups: An array of column groups. Each element of the array can be
- *     either:
- *     - An array of columns, each of which is an associative array of HTML
- *       attributes applied to the COL element.
- *     - An array of attributes applied to the COLGROUP element, which must
- *       include a "data" attribute. To add attributes to COL elements, set the
- *       "data" attribute with an array of columns, each of which is an
- *       associative array of HTML attributes.
- *     Here's an example for $colgroup:
- *     @code
- *     $colgroup = array(
- *       // COLGROUP with one COL element.
- *       array(
- *         array(
- *           'class' => array('funky'), // Attribute for the COL element.
- *         ),
- *       ),
- *       // Colgroup with attributes and inner COL elements.
- *       array(
- *         'data' => array(
- *           array(
- *             'class' => array('funky'), // Attribute for the COL element.
- *           ),
- *         ),
- *         'class' => array('jazzy'), // Attribute for the COLGROUP element.
- *       ),
- *     );
- *     @endcode
- *     These optional tags are used to group and set properties on columns
- *     within a table. For example, one may easily group three columns and
- *     apply same background style to all.
- *   - sticky: Use a "sticky" table header.
- *   - empty: The message to display in an extra row if table does not have any
- *     rows.
  */
-function theme_table($variables) {
-  $header = $variables['header'];
-  $rows = $variables['rows'];
-  $attributes = $variables['attributes'];
-  $caption = $variables['caption'];
-  $colgroups = $variables['colgroups'];
-  $sticky = $variables['sticky'];
-  $responsive = $variables['responsive'];
-  $empty = $variables['empty'];
+function template_preprocess_table(&$variables) {
+  $header = &$variables['header'];
+  $rows = &$variables['rows'];
+  $attributes = &$variables['attributes'];
+  $caption = &$variables['caption'];
+  $colgroups = &$variables['colgroups'];
+  $sticky = &$variables['sticky'];
+  $responsive = &$variables['responsive'];
+  $empty = &$variables['empty'];
 
   // Add sticky headers, if applicable.
   if (count($header) && $sticky) {
@@ -1891,43 +1811,12 @@ function theme_table($variables) {
     $attributes['class'][] = 'responsive-enabled';
   }
 
-  $output = '<table' . new Attribute($attributes) . ">\n";
-
-  if (isset($caption)) {
-    $output .= '<caption>' . $caption . "</caption>\n";
-  }
-
   // Format the table columns:
   if (count($colgroups)) {
-    foreach ($colgroups as $number => $colgroup) {
-      $attributes = array();
-
+    foreach ($colgroups as $number => &$colgroup) {
       // Check if we're dealing with a simple or complex column
-      if (isset($colgroup['data'])) {
-        foreach ($colgroup as $key => $value) {
-          if ($key == 'data') {
-            $cols = $value;
-          }
-          else {
-            $attributes[$key] = $value;
-          }
-        }
-      }
-      else {
-        $cols = $colgroup;
-      }
-
-      // Build colgroup
-      if (is_array($cols) && count($cols)) {
-        $output .= ' <colgroup' . new Attribute($attributes) . '>';
-        $i = 0;
-        foreach ($cols as $col) {
-          $output .= ' <col' . new Attribute($col) . ' />';
-        }
-        $output .= " </colgroup>\n";
-      }
-      else {
-        $output .= ' <colgroup' . new Attribute($attributes) . " />\n";
+      if (!isset($colgroup['data'])) {
+        $colgroup = array('data' => $colgroup);
       }
     }
   }
@@ -1952,9 +1841,8 @@ function theme_table($variables) {
     $ts = tablesort_init($header);
     // HTML requires that the thead tag has tr tags in it followed by tbody
     // tags. Using ternary operator to check and see if we have any rows.
-    $output .= (count($rows) ? ' <thead><tr>' : ' <tr>');
     $i = 0;
-    foreach ($header as $cell) {
+    foreach ($header as &$cell) {
       $i++;
       // Track responsive classes for each column as needed. Only the header
       // cells for a column are marked up with the responsive classes by a
@@ -1969,10 +1857,7 @@ function theme_table($variables) {
         }
       }
       $cell = tablesort_header($cell, $header, $ts);
-      $output .= _theme_table_cell($cell, TRUE);
     }
-    // Using ternary operator to close the tags based on whether or not there are rows
-    $output .= (count($rows) ? " </tr></thead>\n" : "</tr>\n");
   }
   else {
     $ts = array();
@@ -1980,37 +1865,22 @@ function theme_table($variables) {
 
   // Format the table rows:
   if (count($rows)) {
-    $output .= "<tbody>\n";
     $flip = array('even' => 'odd', 'odd' => 'even');
     $class = 'even';
-    foreach ($rows as $number => $row) {
-      $attributes = array();
-
+    foreach ($rows as $number => &$row) {
       // Check if we're dealing with a simple or complex row
-      if (isset($row['data'])) {
-        foreach ($row as $key => $value) {
-          if ($key == 'data') {
-            $cells = $value;
-          }
-          else {
-            $attributes[$key] = $value;
-          }
-        }
-      }
-      else {
-        $cells = $row;
+      if (!isset($row['data'])) {
+        $row = array('data' => $row);
       }
-      if (count($cells)) {
+      if (count($row['data'])) {
         // Add odd/even class
         if (empty($row['no_striping'])) {
           $class = $flip[$class];
-          $attributes['class'][] = $class;
+          $row['class'][] = $class;
         }
 
-        // Build row
-        $output .= ' <tr' . new Attribute($attributes) . '>';
         $i = 0;
-        foreach ($cells as $cell) {
+        foreach ($row['data'] as &$cell) {
           $i++;
           // Add active class if needed for sortable tables.
           $cell = tablesort_cell($cell, $header, $ts, $i);
@@ -2024,6 +1894,76 @@ function theme_table($variables) {
               $cell = array('data' => $cell, 'class' => $responsive[$i]);
             }
           }
+        }
+      }
+    }
+  }
+}
+
+function theme_table($variables) {
+  $header = $variables['header'];
+  $rows = $variables['rows'];
+  $attributes = $variables['attributes'];
+  $caption = $variables['caption'];
+  $colgroups = $variables['colgroups'];
+  $sticky = $variables['sticky'];
+  $responsive = $variables['responsive'];
+  $empty = $variables['empty'];
+
+  //print_r($variables);
+
+  $output = '<table' . new Attribute($attributes) . ">\n";
+
+  if (isset($caption)) {
+    $output .= '<caption>' . $caption . "</caption>\n";
+  }
+
+  // Format the table columns:
+  if (count($colgroups)) {
+    foreach ($colgroups as $number => $colgroup) {
+      $cols = $colgroup['data'];
+      $attributes = $colgroup;
+      unset($attributes['data']);
+
+      // Build colgroup
+      if (is_array($cols) && count($cols)) {
+        $output .= ' <colgroup' . new Attribute($attributes) . '>';
+        $i = 0;
+        foreach ($cols as $col) {
+          $output .= ' <col' . new Attribute($col) . ' />';
+        }
+        $output .= " </colgroup>\n";
+      }
+      else {
+        $output .= ' <colgroup' . new Attribute($attributes) . " />\n";
+      }
+    }
+  }
+
+  // Format the table header:
+  if (count($header)) {
+    // HTML requires that the thead tag has tr tags in it followed by tbody
+    // tags. Using ternary operator to check and see if we have any rows.
+    $output .= (count($rows) ? ' <thead><tr>' : ' <tr>');
+    foreach ($header as $cell) {
+      $output .= _theme_table_cell($cell, TRUE);
+    }
+    // Using ternary operator to close the tags based on whether or not there are rows
+    $output .= (count($rows) ? " </tr></thead>\n" : "</tr>\n");
+  }
+
+  // Format the table rows:
+  if (count($rows)) {
+    $output .= "<tbody>\n";
+    foreach ($rows as $number => $row) {
+      $cells = $row['data'];
+      $attributes = $row;
+      unset($attributes['data']);
+
+      if (count($cells)) {
+        // Build row
+        $output .= ' <tr' . new Attribute($attributes) . '>';
+        foreach ($cells as $cell) {
           $output .= _theme_table_cell($cell);
         }
         $output .= " </tr>\n";
