 elysia_cron.info    |    1 +
 elysia_cron.install |   11 --------
 elysia_cron.module  |   72 +++++++++-----------------------------------------
 3 files changed, 14 insertions(+), 70 deletions(-)

diff --git a/elysia_cron.info b/elysia_cron.info
index a191e3e..d723f9c 100644
--- a/elysia_cron.info
+++ b/elysia_cron.info
@@ -1,6 +1,7 @@
 name = "Elysia Cron"
 description = "Extended cron support with crontab-like scheduling and other features."
 core = 7.x
+dependencies[] = ctools
 files[] = elysia_cron_update.php
 files[] = elysia_drupalconv.php
 configure = admin/config/system/cron
\ No newline at end of file
diff --git a/elysia_cron.install b/elysia_cron.install
index 106aaf7..014b458 100644
--- a/elysia_cron.install
+++ b/elysia_cron.install
@@ -13,7 +13,6 @@ function elysia_cron_schema() {
         'size' => 'tiny',
         'not null' => TRUE,
         'default' => 0,
-        'no export' => TRUE,
       ),
       'rule' => array(
         'type' => 'varchar',
@@ -31,61 +30,51 @@ function elysia_cron_schema() {
         'type' => 'int',
         'not null' => TRUE,
         'default' => 0,
-        'no export' => TRUE,
       ),
       'last_run' => array(
         'type' => 'int',
         'not null' => TRUE,
         'default' => 0,
-        'no export' => TRUE,
       ),
       'last_aborted' => array(
         'type' => 'int',
         'size' => 'tiny',
         'not null' => TRUE,
         'default' => 0,
-        'no export' => TRUE,
       ),
       'abort_count' => array(
         'type' => 'int',
         'not null' => TRUE,
         'default' => 0,
-        'no export' => TRUE,
       ),
       'last_abort_function' => array(
         'type' => 'varchar',
         'length' => 32,
-        'no export' => TRUE,
       ),
       'last_execution_time' => array(
         'type' => 'int',
         'not null' => TRUE,
         'default' => 0,
-        'no export' => TRUE,
       ),
       'execution_count' => array(
         'type' => 'int',
         'not null' => TRUE,
         'default' => 0,
-        'no export' => TRUE,
       ),
       'avg_execution_time' => array(
         'type' => 'float',
         'not null' => TRUE,
         'default' => 0,
-        'no export' => TRUE,
       ),
       'max_execution_time' => array(
         'type' => 'int',
         'not null' => TRUE,
         'default' => 0,
-        'no export' => TRUE,
       ),
       'last_shutdown_time' => array(
         'type' => 'int',
         'not null' => TRUE,
         'default' => 0,
-        'no export' => TRUE,
       ),
     ),
     'primary key' => array('name'),
diff --git a/elysia_cron.module b/elysia_cron.module
index a9de366..8539cae 100644
--- a/elysia_cron.module
+++ b/elysia_cron.module
@@ -319,73 +319,27 @@ function elysia_cron_set($name, $channel = false, $values = array()) {
   if ($channel) {
     $name = ':' . $name;
   }
-
-  if (EC_DRUPAL_VERSION >= 7) {
-    db_merge('elysia_cron')->key(array('name' => $name))->fields($values)->execute();
-    
-  } else {
-    $fields = array("name" => "'%s'", "disabled" => "%d", "rule" => "'%s'", "weight" => "%d", "context" => "'%s'", "running" => "%d", "last_run" => "%d", "last_aborted" => "%d", "abort_count" => "%d", "last_abort_function" => "'%s'", "last_execution_time" => "%d", "execution_count" => "%d", "avg_execution_time" => "%f", "max_execution_time" => "%d", "last_shutdown_time" => "%d");
-    $ifields = array('disabled', 'running', 'last_run', 'last_aborted', 'abort_count', 'last_execution_time', 'execution_count', 'avg_execution_time', 'max_execution_time', 'last_shutdown_time');
-    
-    $uquery = array();
-    $uvalues = array();
-    foreach ($values as $k => $v) {
-      if (is_null($v) && !in_array($k, $ifields)) {
-        $uquery[] =  $k . ' = NULL';
-      }
-      else {
-        $uquery[] =  $k . ' = ' . $fields[$k];
-        $uvalues[] = $v;
-      }
-    }
-    $uvalues[] = $name;
-
-    db_query("update {elysia_cron} set " . implode(', ', $uquery) . " where name = '%s'", $uvalues);
-    if (!db_affected_rows()) {
-      foreach ($ifields as $f) {
-        if (empty($values[$f])) {
-          $values[$f] = 0;
-        }
-      }
-      $values['name'] = $name;
-
-      $iquery1 = array();
-      $iquery2 = array();
-      $ivalues = array();
-      foreach ($values as $k => $v) {
-        if (!is_null($v)) {
-          $iquery1[] = $k;
-          $iquery2[] = $fields[$k];
-          $ivalues[] = $v;
-        }
-      }
-
-      db_query("insert into {elysia_cron} (" . implode(', ', $iquery1) . ") values (" . implode(', ', $iquery2) . ")", $ivalues);
-    }
+  ctools_include('export');
+  $cron_rule = ctools_export_crud_new('elysia_cron');
+  $cron_rule->name = $name;
+  foreach ($values as $k => $v) {
+    $cron_rule->$k = $v;
   }
-
-  global $elysia_cron_db_cache;
-
-  unset($elysia_cron_db_cache[$name]);
+  $cron_rule->rule = '';
+  $cron_rule->weight = 0;
+  $cron_rule->context = '';
+  $cron_rule->last_abort_function = '';
+  dsm($cron_rule);
+  ctools_export_crud_save('elysia_cron', $cron_rule);
 }
 
 function elysia_cron_get($name, $channel = false, $key, $default, $refresh = false) {
-  global $elysia_cron_db_cache;
-
   if ($channel) {
     $name = ':' . $name;
   }
 
-  if ($refresh || !isset($elysia_cron_db_cache[$name])) {
-    if (EC_DRUPAL_VERSION >= 7) {
-      $elysia_cron_db_cache[$name] = db_query("select * from {elysia_cron} where name = :name", array(':name' => $name))->fetchAssoc();
-    }
-    else {
-      $elysia_cron_db_cache[$name] = db_fetch_array(db_query("select * from {elysia_cron} where name = '%s'", $name));
-    }
-  }
-
-  return !$elysia_cron_db_cache[$name] || is_null($elysia_cron_db_cache[$name][$key]) ? $default : $elysia_cron_db_cache[$name][$key];
+  ctools_include('export');
+  return (array)ctools_export_crud_load('elysia_cron', $name);
 }
 
 function elysia_cron_is_channel_disabled($channel, $default = false, $refresh = false) {
