diff --git a/css3pie.module b/css3pie.module
index 327630f..07f0394 100644
--- a/css3pie.module
+++ b/css3pie.module
@@ -8,6 +8,11 @@
  */
 
 /**
+ * Define a cache key for storing the CTools CSS file id.
+ */
+define('CSS3PIE_CSS_CACHE_KEY', 'css3pie_css_cache');
+
+/**
  * Implements hook_permission()
  * only users with "administer css3pie" permission can edit
  * the settings form.
@@ -93,7 +98,7 @@ function css3pie_css3pie() {
 function css3pie_preprocess_html(&$vars) {
   ctools_include('css');
   // get the path of css3pie file
-  $path_to_css3pie_css_file = ctools_css_retrieve('css3pie_css');
+  $path_to_css3pie_css_file = _css3pie_build_css3pie_css();
   $path_to_css3pie_js_file = file_default_scheme() . '://css3pie/css3pie.js';
   
   $piejslibrary = drupal_get_library('css3pie', 'css3pie_js');
@@ -172,21 +177,8 @@ function _css3pie_build_css3pie_functionality() {
     _css3pie_build_css3pie_js();
   }
   else {
-    _css3pie_build_css3pie_css();
-  }
-}
-
-/**
- * Implements hook_init
- */
-
-function css3pie_init() {
-  if (variable_get('css3pie_css_use_js_mode', FALSE) || $cache = cache_get('css3pie_css_cache', 'cache')) {
-    return;
-    
-  }
-  else {
-    _css3pie_build_css3pie_css();
+    // We can just clear the cache, and let the file get rebuilt on demand.
+    cache_clear_all(CSS3PIE_CSS_CACHE_KEY, 'cache');
   }
 }
 
@@ -196,6 +188,16 @@ function css3pie_init() {
  * @return <type> path to new created file
  */
 function _css3pie_build_css3pie_css() {
+  $cache = cache_get(CSS3PIE_CSS_CACHE_KEY);
+  if (!empty($cache) && !empty($cache->data)) {
+    // Try to get that CSS file from ctools.
+    if ($filename = ctools_css_retrieve($cache->data)) {
+      return $filename;
+    }
+  }
+
+  // Otherwise we actually need to compute the ID of the stored CSS.
+
   $output = '';
 
   // invoke hook_css3pie in all modules to get the selectors
@@ -239,7 +241,17 @@ function _css3pie_build_css3pie_css() {
   
   }
   
-  return _css3pie_create_css3pie_css($output);
+  // Hash the CSS that is stored to generate the CTools CSS ID.
+  $id = md5($output);
+  cache_set(CSS3PIE_CSS_CACHE_KEY, $id);
+  // Try to get the file from CTools.
+  if ($filename = ctools_css_retrieve($id)) {
+    return $filename;
+  }
+  else {
+    // Otherwise store in the CTools CSS store.
+    return ctools_css_store($id, $output, FALSE);
+  }
 }
 
 /**
@@ -272,34 +284,6 @@ function _css3pie_build_css3pie_js() {
 }
 
 /**
- * helper function creates a real css file within files directory using new drupal streamwrapper
- * that be can added via drupal_add_css();
- *
- * @param <type> $css - the css markup
- * @return <type>
- */
-function _css3pie_create_css3pie_css($css = NULL) {
-  if (!$css) {
-    return FALSE;
-  }
-  
-  ctools_include('css');
-  ctools_css_clear('css3pie_css');
-  
-  // Create Ctools CSS cache item
-  if($filename = ctools_css_store('css3pie_css', $css, FALSE)) {
-  
-    // Set generated filename to cache
-    cache_set('css3pie_css_cache', $filename);
-
-    return $filename;
-  }
-  else {
-    return FALSE;
-  }
-}
-
-/**
  * helper function creates a real js file within files directory using new drupal streamwrapper;
  *
  * @param <type> $css - the css markup
