diff --git a/includes/common.inc b/includes/common.inc
index 05af5a7..3e90011 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -1741,11 +1741,13 @@ function drupal_add_link($attributes) {
 }
 
 /**
- * Adds a CSS file to the stylesheet queue.
+ * Adds a cascading stylesheet to the stylesheet queue.
  *
- * @param $path
- *   (optional) The path to the CSS file relative to the base_path(), e.g.,
- *   modules/devel/devel.css.
+ * @param $data
+ *   (optional) The stylesheet data to be added, depending on what is passed
+ *   through to the $type parameter:
+ *   - 'module' or 'theme': The path to the CSS file relative to the base_path(),
+ *     e.g., "modules/devel/devel.css".
  *
  *   Modules should always prefix the names of their CSS files with the module
  *   name, for example: system-menus.css rather than simply menus.css. Themes
@@ -1760,9 +1762,12 @@ function drupal_add_link($attributes) {
  *   file added to the list, if exists in the same directory. This CSS file
  *   should contain overrides for properties which should be reversed or
  *   otherwise different in a right-to-left display.
+ *   - 'inline': A string of CSS that should be placed in the given scope. Note
+ *     that it is better practice to use 'module' or 'theme' stylesheets, rather
+ *     than 'inline' as the CSS would then be aggregated and cached.
  * @param $type
- *   (optional) The type of stylesheet that is being added. Types are: module
- *   or theme.
+ *   (optional) The type of stylesheet that is being added. Types are: 'module',
+ *   'theme' or 'inline'. Defaults to 'module'.
  * @param $media
  *   (optional) The media type for the stylesheet, e.g., all, print, screen.
  * @param $preprocess
@@ -1788,28 +1793,25 @@ function drupal_add_link($attributes) {
  *
  *   Typical candidates for caching are for example styles for nodes across
  *   the site, or used in the theme.
- *
  * @return
- *   An array of CSS files.
- *
- * @see drupal_get_css()
+ *   An array of queued cascading stylesheets.
  */
-function drupal_add_css($path = NULL, $type = 'module', $media = 'all', $preprocess = TRUE) {
+function drupal_add_css($data = NULL, $type = 'module', $media = 'all', $preprocess = TRUE) {
   static $css = array();
   global $language;
 
   // Create an array of CSS files for each media type first, since each type needs to be served
   // to the browser differently.
-  if (isset($path)) {
+  if (isset($data)) {
     // This check is necessary to ensure proper cascading of styles and is faster than an asort().
     if (!isset($css[$media])) {
-      $css[$media] = array('module' => array(), 'theme' => array());
+      $css[$media] = array('module' => array(), 'theme' => array(), 'inline' => array());
     }
-    $css[$media][$type][$path] = $preprocess;
+    $css[$media][$type][$data] = $preprocess;
 
     // If the current language is RTL, add the CSS file with RTL overrides.
-    if ($language->direction == LANGUAGE_RTL) {
-      $rtl_path = str_replace('.css', '-rtl.css', $path);
+    if ($type != 'inline' && $language->direction == LANGUAGE_RTL) {
+      $rtl_path = str_replace('.css', '-rtl.css', $data);
       if (file_exists($rtl_path)) {
         $css[$media][$type][$rtl_path] = $preprocess;
       }
@@ -1841,8 +1843,6 @@ function drupal_add_css($path = NULL, $type = 'module', $media = 'all', $preproc
  *
  * @return
  *   A string of XHTML CSS tags.
- *
- * @see drupal_add_css()
  */
 function drupal_get_css($css = NULL) {
   $output = '';
@@ -1851,6 +1851,7 @@ function drupal_get_css($css = NULL) {
   }
   $no_module_preprocess = '';
   $no_theme_preprocess = '';
+  $no_inline_preprocess = '';
 
   $preprocess_css = (variable_get('preprocess_css', FALSE) && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update'));
   $directory = file_directory_path();
@@ -1865,7 +1866,7 @@ function drupal_get_css($css = NULL) {
   foreach ($css as $media => $types) {
     // If CSS preprocessing is off, we still need to output the styles.
     // Additionally, go through any remaining styles if CSS preprocessing is on and output the non-cached ones.
-    foreach ($types as $type => $files) {
+    foreach ($types as $type => $information) {
       if ($type == 'module') {
         // Setup theme overrides for module styles.
         $theme_styles = array();
@@ -1873,29 +1874,33 @@ function drupal_get_css($css = NULL) {
           $theme_styles[] = basename($theme_style);
         }
       }
-      foreach ($types[$type] as $file => $preprocess) {
+      foreach ($types[$type] as $data => $preprocess) {
         // If the theme supplies its own style using the name of the module style, skip its inclusion.
         // This includes any RTL styles associated with its main LTR counterpart.
-        if ($type == 'module' && in_array(str_replace('-rtl.css', '.css', basename($file)), $theme_styles)) {
+        if ($type == 'module' && in_array(str_replace('-rtl.css', '.css', basename($data)), $theme_styles)) {
           // Unset the file to prevent its inclusion when CSS aggregation is enabled.
-          unset($types[$type][$file]);
+          unset($types[$type][$data]);
           continue;
         }
+        // Include inline stylesheets.
+        if ($type == 'inline') {
+          $no_inline_preprocess .= drupal_load_stylesheet_content($data, $preprocess);
+        }
         // Only include the stylesheet if it exists.
-        if (file_exists($file)) {
+        elseif (file_exists($data)) {
           if (!$preprocess || !($is_writable && $preprocess_css)) {
             // If a CSS file is not to be preprocessed and it's a module CSS file, it needs to *always* appear at the *top*,
             // regardless of whether preprocessing is on or off.
             if (!$preprocess && $type == 'module') {
-              $no_module_preprocess .= '<link type="text/css" rel="stylesheet" media="'. $media .'" href="'. base_path() . $file . $query_string .'" />'."\n";
+              $no_module_preprocess .= '<link type="text/css" rel="stylesheet" media="' . $media . '" href="' . base_path() . $data . $query_string . '" />' . "\n";
             }
             // If a CSS file is not to be preprocessed and it's a theme CSS file, it needs to *always* appear at the *bottom*,
             // regardless of whether preprocessing is on or off.
             else if (!$preprocess && $type == 'theme') {
-              $no_theme_preprocess .= '<link type="text/css" rel="stylesheet" media="'. $media .'" href="'. base_path() . $file . $query_string .'" />'."\n";
+              $no_theme_preprocess .= '<link type="text/css" rel="stylesheet" media="' . $media . '" href="' . base_path() . $data . $query_string . '" />' . "\n";
             }
             else {
-              $output .= '<link type="text/css" rel="stylesheet" media="'. $media .'" href="'. base_path() . $file . $query_string .'" />'."\n";
+              $output .= '<link type="text/css" rel="stylesheet" media="' . $media . '" href="' . base_path() . $data . $query_string . '" />' . "\n";
             }
           }
         }
@@ -1910,8 +1915,10 @@ function drupal_get_css($css = NULL) {
       $output .= '<link type="text/css" rel="stylesheet" media="'. $media .'" href="'. base_path() . $preprocess_file .'" />'."\n";
     }
   }
-
-  return $no_module_preprocess . $output . $no_theme_preprocess;
+  if (!empty($no_inline_preprocess)) {
+    $no_inline_preprocess = '<style type="text/css">' . $no_inline_preprocess . '</style>';
+  }
+  return $no_module_preprocess . $output . $no_theme_preprocess . $no_inline_preprocess;
 }
 
 /**
@@ -1934,18 +1941,21 @@ function drupal_build_css_cache($types, $filename) {
 
   if (!file_exists($csspath .'/'. $filename)) {
     // Build aggregate CSS file.
-    foreach ($types as $type) {
-      foreach ($type as $file => $cache) {
+    foreach ($types as $type => $css) {
+      // Only 'module' or 'theme' stylesheets can be aggregated.
+      if ($type == 'module' || $type == 'theme') {
+        foreach ($css as $stylesheet => $cache) {
         if ($cache) {
-          $contents = drupal_load_stylesheet($file, TRUE);
+            $contents = drupal_load_stylesheet($stylesheet, TRUE);
           // Return the path to where this CSS file originated from.
-          $base = base_path() . dirname($file) .'/';
+            $base = base_path() . dirname($stylesheet) . '/';
           _drupal_build_css_path(NULL, $base);
           // Prefix all paths within this CSS file, ignoring external and absolute paths.
           $data .= preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', '_drupal_build_css_path', $contents);
         }
       }
     }
+    }
 
     // Per the W3C specification at http://www.w3.org/TR/REC-CSS2/cascade.html#at-import,
     // @import rules must proceed any other style, so we move those to the top.
@@ -1998,7 +2008,7 @@ function _drupal_build_css_path($matches, $base = NULL) {
  * @param $optimize
  *   Defines if CSS contents should be compressed or not.
  * @return
- *   Contents of the stylesheet including the imported stylesheets.
+ *   Contents of the stylesheet, including any resolved @import commands.
  */
 function drupal_load_stylesheet($file, $optimize = NULL) {
   static $_optimize;
@@ -2016,30 +2026,8 @@ function drupal_load_stylesheet($file, $optimize = NULL) {
     $cwd = getcwd();
     chdir(dirname($file));
 
-    // Replaces @import commands with the actual stylesheet content.
-    // This happens recursively but omits external files.
-    $contents = preg_replace_callback('/@import\s*(?:url\()?[\'"]?(?![a-z]+:)([^\'"\()]+)[\'"]?\)?;/', '_drupal_load_stylesheet', $contents);
-    // Remove multiple charset declarations for standards compliance (and fixing Safari problems).
-    $contents = preg_replace('/^@charset\s+[\'"](\S*)\b[\'"];/i', '', $contents);
-
-    if ($_optimize) {
-      // Perform some safe CSS optimizations.
-      // Regexp to match comment blocks.
-      $comment     = '/\*[^*]*\*+(?:[^/*][^*]*\*+)*/';
-      // Regexp to match double quoted strings.
-      $double_quot = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"';
-      // Regexp to match single quoted strings.
-      $single_quot = "'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'";
-      $contents = preg_replace_callback(
-        "<$double_quot|$single_quot|$comment>Ss",  // Match all comment blocks along
-        "_process_comment",                        // with double/single quoted strings
-        $contents);                                // and feed them to _process_comment().
-      $contents = preg_replace(
-        '<\s*([@{}:;,]|\)\s|\s\()\s*>S',           // Remove whitespace around separators,
-        '\1', $contents);                          // but keep space around parentheses.
-      // End the file with a new line.
-      $contents .= "\n";
-    }
+    // Process the stylesheet.
+    $contents = drupal_load_stylesheet_content($contents, $_optimize);
 
     // Change back directory.
     chdir($cwd);
@@ -2084,6 +2072,35 @@ function _process_comment($matches) {
 }
 
 /**
+ * Process the contents of a stylesheet for aggregation.
+ *
+ * @param $contents
+ *   The contents of the stylesheet.
+ * @param $optimize
+ *   (optional) Boolean whether CSS contents should be minified. Defaults to
+ *   FALSE.
+ * @return
+ *   Contents of the stylesheet including the imported stylesheets.
+ */
+function drupal_load_stylesheet_content($contents, $optimize = FALSE) {  
+  // Replaces @import commands with the actual stylesheet content.
+  // This happens recursively but omits external files.
+  $contents = preg_replace_callback('/@import\s*(?:url\()?[\'"]?(?![a-z]+:)([^\'"\()]+)[\'"]?\)?;/', '_drupal_load_stylesheet', $contents);
+  // Remove multiple charset declarations for standards compliance (and fixing Safari problems).
+  $contents = preg_replace('/^@charset\s+[\'"](\S*)\b[\'"];/i', '', $contents);
+
+  if ($optimize) {
+    // Perform some safe CSS optimizations.
+    $contents = preg_replace('<
+      \s*([@{}:;,]|\)\s|\s\()\s* |  # Remove whitespace around separators, but keep space around parentheses.
+      /\*([^*\\\\]|\*(?!/))+\*/ |   # Remove comments that are not CSS hacks.
+      [\n\r]                        # Remove line breaks.
+      >x', '\1', $contents);
+  }
+  return $contents;
+}
+
+/**
  * Loads stylesheets recursively and returns contents with corrected paths.
  *
  * This function is used for recursive loading of stylesheets and
