diff --git a/fullcalendar_colors/fullcalendar_colors.module b/fullcalendar_colors/fullcalendar_colors.module
index 0babeb4..d887e0a 100644
--- a/fullcalendar_colors/fullcalendar_colors.module
+++ b/fullcalendar_colors/fullcalendar_colors.module
@@ -74,6 +74,18 @@ function fullcalendar_colors_help($path, $arg) {
   }
 }
 
+/**
+ * Process FullCalendar Colors after the structure is built.
+ */
+function fullcalendar_colors_preprocess_fullcalendar(&$variables) {
+  ctools_include('css');
+  $filename = ctools_css_retrieve('colors');
+  if (!$filename) {
+    $filename = fullcalendar_colors_create_css_file();
+  }
+  $variables['element']['#attached']['css'][] = $filename;
+}
+
 function fullcalendar_colors_include_api() {
   ctools_include('plugins');
   return ctools_plugin_api_include('fullcalendar_colors', 'fullcalendar_colors', fullcalendar_colors_api_version(), fullcalendar_colors_api_minimum_version());
@@ -259,5 +271,22 @@ function fullcalendar_colors_set_color($classes, $background = '#000000', $borde
     'border' => $border,
     'text' => $text,
   );
-  colors_set_colors($classes, $colors, 'fullcalendar_colors');
+  $old = serialize(colors_get_colors($classes, 'fullcalendar_colors'));
+  $new = serialize($colors);
+  if ($old != $new) {
+    colors_set_colors($classes, $colors, 'fullcalendar_colors');
+    ctools_include('css');
+    ctools_css_clear('colors');
+  }
+}
+
+function fullcalendar_colors_create_css_file($default_colors = array()) {
+  ctools_include('css');
+  $css = '';
+  foreach (module_implements('colors_build_selector') as $module) {
+    foreach (colors_get_module_colors($module) as $selector => $colors) {
+      $css .= colors_build_css($selector, $colors, $module, $default_colors);
+    }
+  }
+  return ctools_css_store('colors', $css);
 }
diff --git a/fullcalendar_colors/includes/fullcalendar_colors.admin.inc b/fullcalendar_colors/includes/fullcalendar_colors.admin.inc
index f06a1b3..90b1ef2 100644
--- a/fullcalendar_colors/includes/fullcalendar_colors.admin.inc
+++ b/fullcalendar_colors/includes/fullcalendar_colors.admin.inc
@@ -385,12 +385,19 @@ function fullcalendar_colors_admin_settings() {
 function fullcalendar_colors_admin_settings_submit($form, &$form_state) {
   fullcalendar_colors_set_color('fullcalendar_colors_default', $form_state['values']['default_color']['input']);
   variable_set('fullcalendar_colors_process_order_enabled', $form_state['values']['process_order']['enabled']);
+  $change = FALSE;
 
   foreach ($form_state['values']['modules'] as $module => $weight) {
     if ($form['modules'][$module]['#weight'] != $weight['weight']) {
+      $change = TRUE;
       variable_set('fullcalendar_colors_weight_' . $module, $weight['weight']);
     }
   }
+
+  if ($change) {
+    ctools_include('css');
+    ctools_css_clear('colors');
+  }
 }
 
 /**
diff --git a/theme/theme.inc b/theme/theme.inc
index 8021fdb..c452857 100644
--- a/theme/theme.inc
+++ b/theme/theme.inc
@@ -53,15 +53,6 @@ function template_preprocess_fullcalendar(&$variables) {
 }
 
 /**
- * Process FullCalendar Colors after the structure is built.
- */
-function template_process_fullcalendar(&$variables) {
-  if (module_exists('fullcalendar_colors')) {
-    fullcalendar_colors_process_selectors(array(), TRUE);
-  }
-}
-
-/**
  * Render the FullCalendar.
  */
 function theme_fullcalendar($variables) {
@@ -263,7 +254,6 @@ function fullcalendar_prepare_events($view, $rows, $options) {
 
      // Create a string of class names.
     $classes = array();
-    $colors = array();
     foreach (module_implements('fullcalendar_classes') as $module) {
       // Fetch all the class names.
       $function = $module . '_fullcalendar_classes';
@@ -271,13 +261,6 @@ function fullcalendar_prepare_events($view, $rows, $options) {
 
       // Merge for normal classes.
       $classes = array_merge($classes, $class_names);
-
-      // Prepare an array for the FullCalendar Colors module.
-      if (module_exists('fullcalendar_colors')) {
-        foreach ($class_names as $class_name) {
-          $colors[$module][$class_name] = $class_name;
-        }
-      }
     }
 
     // Alter the classes array if needed.
@@ -286,11 +269,6 @@ function fullcalendar_prepare_events($view, $rows, $options) {
     // Add classes to the FullCalendar event.
     $entity->class = implode(' ', array_unique($classes));
 
-    // Call FullCalendar Colors when needed.
-    if (module_exists('fullcalendar_colors')) {
-      fullcalendar_colors_generate_css($entity, $colors);
-    }
-
     // Default URL.
     $uri = entity_uri($entity_type, $entity);
     $entity->url = $uri['path'];
