diff --git a/css_injector.module b/css_injector.module
index 81502ed..144f876 100644
--- a/css_injector.module
+++ b/css_injector.module
@@ -33,7 +33,7 @@ function css_injector_init() {
   $css_rules = _css_injector_load_rule();
   foreach ($css_rules as $css_rule) {
     if (_css_injector_evaluate_rule($css_rule)) {
-      drupal_add_css(file_create_path(_css_injector_rule_path($css_rule['crid'])), 'module', $css_rule['media'], $css_rule['preprocess']);
+      _css_injector_add_css(file_create_path(_css_injector_rule_path($css_rule['crid'])), 'module', $css_rule['media'], $css_rule['preprocess']);
     }
   }
 }
@@ -174,3 +174,49 @@ function _css_injector_rule_path($crid) {
   }
   return NULL;
 }
+
+/**
+ * Copied from CTools. Add a css_injector CSS file to the page.
+ *
+ * Because drupal_add_css() does not handle files that it cannot stat, it
+ * can't add files that are stored in a private file system. This will
+ * will check to see if we're using the private file system and use
+ * drupal_set_html_head() instead if that is the case.
+ *
+ * Sadly that will preclude aggregation of any sort, but there doesn't seem to
+ * be any ways around that. Also it will screw with stylesheet order. Again,
+ * sorry.
+ */
+function _css_injector_add_css($filename = NULL, $type = 'module', $media = 'all', $preprocess = TRUE) {
+  switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) {
+    case FILE_DOWNLOADS_PUBLIC:
+      drupal_add_css($filename, $type, $media, $preprocess);
+      break;
+    case FILE_DOWNLOADS_PRIVATE:
+      $path = file_create_path($filename);
+      if ($path) {
+        $url = file_create_url($path);
+      }
+      else {
+        $url = $filename;
+      }
+
+      $output = '<link type="text/css" rel="stylesheet" media="' . $media . '" href="' . $url . '" />'."\n";
+      drupal_set_html_head($output);
+  }
+}
+
+/*
+ * Implementation of hook_file_download().
+ *
+ * Copied from js_injector
+ */
+function css_injector_file_download($filepath) {
+  // Check if the file is controlled by the current module.
+  if (preg_match('/^css_injector_\d+.css$/', $filepath)) {
+    return array(
+      'Content-type:'. mime_header_encode(file_get_mimetype(file_create_path($filepath))),
+    );
+  }
+  return NULL;
+}
