 elysia_cron.install           |  203 ++++++++++++++++++++-
 elysia_cron.module            |  410 +++++++++++++----------------------------
 elysia_cron_scheduler.inc     |    2 +-
 elysia_cron_scheduler_old.inc |  230 -----------------------
 elysia_cron_update.php        |  292 -----------------------------
 elysia_drupalconv.php         |   57 ------
 6 files changed, 330 insertions(+), 864 deletions(-)

diff --git a/elysia_cron.install b/elysia_cron.install
index aec8077..8e72c99 100644
--- a/elysia_cron.install
+++ b/elysia_cron.install
@@ -121,8 +121,6 @@ function elysia_cron_install() {
   }
   db_query("UPDATE {system} SET weight = %d WHERE name = '%s'", $min, 'elysia_cron');
   
-  variable_set('elysia_cron_version', 20100507);
-  
   drupal_set_message('Elysia cron installed. Setup could be found at ' . l(t('Settings page'), 'admin/build/cron/settings') . '. See INSTALL.TXT for more info.');
 }
 
@@ -149,4 +147,203 @@ function elysia_cron_update_1() {
   return array();
 }
 
-// Remember use the new update_xxxx convention (6001...)
\ No newline at end of file
+function elysia_cron_update_6101() {
+  elysia_cron_check_version_update();
+}
+
+function elysia_cron_check_version_update() {
+  $unchanged = array(
+    'elysia_cron_last_context',
+    'elysia_cron_last_run',
+    'elysia_cron_disabled',
+    'elysia_cron_semaphore',
+    'elysia_cron_key',
+    'elysia_cron_allowed_hosts',
+    'elysia_cron_default_rule',
+    'elysia_cron_script',
+    'elysia_cron_runtime_replacement',
+    'elysia_cron_version',
+  );
+
+  $rs = db_query('select * from {variable} where name like "elysia_cron_%%"');
+  while ($v = db_fetch_object($rs)) {
+    if (!in_array($v->name, $unchanged)) {
+      $vn = false;
+      if (preg_match('/^elysia_cron_ctx_(.*)_(running|disabled|last_run|last_aborted|abort_count|execution_count|last_execution_time|avg_execution_time|max_execution_time|last_shutdown_time|last_abort_function)/', $v->name, $r)) {
+        switch ($r[2]) {
+          case 'running':
+            $vn = 'ecc_' . _ec_get_name($r[1]) . '_r';
+            break;
+          case 'disabled':
+            $vn = 'ecc_' . _ec_get_name($r[1]) . '_d';
+            break;
+          case 'last_run':
+            $vn = 'ecc_' . _ec_get_name($r[1]) . '_lr';
+            break;
+          case 'last_aborted':
+            $vn = 'ecc_' . _ec_get_name($r[1]) . '_la';
+            break;
+          case 'abort_count':
+            $vn = 'ecc_' . _ec_get_name($r[1]) . '_ac';
+            break;
+          case 'execution_count':
+            $vn = 'ecc_' . _ec_get_name($r[1]) . '_ec';
+            break;
+          case 'last_execution_time':
+            $vn = 'ecc_' . _ec_get_name($r[1]) . '_let';
+            break;
+          case 'avg_execution_time':
+            $vn = 'ecc_' . _ec_get_name($r[1]) . '_aet';
+            break;
+          case 'max_execution_time':
+            $vn = 'ecc_' . _ec_get_name($r[1]) . '_met';
+            break;
+          case 'last_shutdown_time':
+            $vn = 'ecc_' . _ec_get_name($r[1]) . '_lst';
+            break;
+          case 'last_abort_function':
+            $vn = 'ecc_' . _ec_get_name($r[1]) . '_laf';
+            break;
+        }
+      }
+      elseif (preg_match('/^elysia_cron_(.*)_(rule|disabled|context|running|last_run|last_execution_time|execution_count|avg_execution_time|max_execution_time)/', $v->name, $r)) {
+        switch ($r[2]) {
+          case 'rule':
+            $vn = 'ec_' . _ec_get_name($r[1]) . '_rul';
+            break;
+          case 'disabled':
+            $vn = 'ec_' . _ec_get_name($r[1]) . '_d';
+            break;
+          case 'context':
+            $vn = 'ec_' . _ec_get_name($r[1]) . '_c';
+            break;
+          case 'running':
+            $vn = 'ec_' . _ec_get_name($r[1]) . '_r';
+            break;
+          case 'last_run':
+            $vn = 'ec_' . _ec_get_name($r[1]) . '_lr';
+            break;
+          case 'last_execution_time':
+            $vn = 'ec_' . _ec_get_name($r[1]) . '_let';
+            break;
+          case 'execution_count':
+            $vn = 'ec_' . _ec_get_name($r[1]) . '_ec';
+            break;
+          case 'avg_execution_time':
+            $vn = 'ec_' . _ec_get_name($r[1]) . '_aet';
+            break;
+          case 'max_execution_time':
+            $vn = 'ec_' . _ec_get_name($r[1]) . '_met';
+            break;
+        }
+      }
+      if ($vn) {
+        variable_set($vn, unserialize($v->value));
+      }
+      else {
+        watchdog('cron', 'Error in update, cant convert %name (value: %value)', array('%name' => $v->name, '%value' => $v->value), WATCHDOG_ERROR);
+      }
+
+      variable_del($v->name);
+    }
+  }
+  if (!db_table_exists('elysia_cron')) {
+    drupal_install_schema('elysia_cron');
+
+    $rs = db_query('select * from {variable} where name like "ec_%%" or name like "ecc_%%"');
+    $data = array();
+    $todelete = array();
+    while ($v = db_fetch_object($rs)) {
+      $name = false;
+      if (preg_match('/^ecc_(.+)_(r|d|lr|la|ac|ec|let|aet|met|lst|laf)/', $v->name, $r)) {
+        $name = ':' . $r[1];
+      }
+      elseif (preg_match('/^ec_(.+)_(rul|d|c|w|r|lr|let|ec|aet|met)/', $v->name, $r)) {
+        $name = $r[1];
+      }
+      if ($name) {
+        if (!isset($data[$name])) {
+          $data[$name] = array('name' => $name);
+        }
+        switch ($r[2]) {
+          case 'r':
+            $f = 'running';
+            break;
+          case 'd':
+            $f = 'disabled';
+            break;
+          case 'rul':
+            $f = 'rule';
+            break;
+          case 'w':
+            $f = 'weight';
+            break;
+          case 'c':
+            $f = 'context';
+            break;
+          case 'lr':
+            $f = 'last_run';
+            break;
+          case 'la':
+            $f = 'last_aborted';
+            break;
+          case 'ac':
+            $f = 'abort_count';
+            break;
+          case 'laf':
+            $f = 'last_abort_function';
+            break;
+          case 'let':
+            $f = 'last_execution_time';
+            break;
+          case 'ec':
+            $f = 'execution_count';
+            break;
+          case 'aet':
+            $f = 'avg_execution_time';
+            break;
+          case 'met':
+            $f = 'max_execution_time';
+            break;
+          case 'lst':
+            $f = 'last_shutdown_time';
+            break;
+        }
+        $data[$name][$f] = unserialize($v->value);
+        $todelete[] = $v->name;
+      }
+    }
+
+    $ifields = array('disabled', 'weight', 'running', 'last_run', 'last_aborted', 'abort_count', 'last_execution_time', 'execution_count', 'avg_execution_time', 'max_execution_time', 'last_shutdown_time');
+    foreach ($data as $v) {
+      foreach ($ifields as $f) {
+        if (empty($v[$f])) {
+          $v[$f] = 0;
+        }
+      }
+      db_query("insert into {elysia_cron} (name, disabled, rule, weight, context, running, last_run, last_aborted, abort_count, last_abort_function, last_execution_time, execution_count, avg_execution_time, max_execution_time, last_shutdown_time)
+        values ('%s', %d, '%s', %d, '%s', %d, %d, %d, %d, '%s', %d, %d, %f, %d, %d)",
+        $v['name'], $v['disabled'], $v['rule'], $v['weight'], $v['context'], $v['running'], $v['last_run'], $v['last_aborted'], $v['abort_count'], $v['last_abort_function'], $v['last_execution_time'], $v['execution_count'], $v['avg_execution_time'], $v['max_execution_time'], $v['last_shutdown_time']
+      );
+    }
+
+    db_query("update {elysia_cron} set context = null where context = ''");
+    db_query("update {elysia_cron} set rule = null where rule = ''");
+
+    foreach ($todelete as $v) {
+      variable_del($v);
+      db_query("DELETE FROM {variable} WHERE name = '%s'", $v);
+    }
+
+    unset($GLOBALS['_ec_variables']);
+  }
+  $ret = array();
+  db_change_field($ret, 'elysia_cron', 'weight', 'weight', array('type' => 'int', 'not null' => FALSE));
+  
+  $default_rules = variable_get('elysia_cron_default_rules', $GLOBALS['elysia_cron_default_rules']);
+  if (!empty($default_rules['*/6 * * * *']) && $default_rules['*/6 * * * *'] == 'Every 6 hours') {
+    unset($default_rules['*/6 * * * *']);
+    $default_rules['0 */6 * * *'] = 'Every 6 hours';
+    variable_set('elysia_cron_default_rules', $default_rules);
+  }
+}
diff --git a/elysia_cron.module b/elysia_cron.module
index adf524e..a08b91e 100644
--- a/elysia_cron.module
+++ b/elysia_cron.module
@@ -1,6 +1,4 @@
 <?php
-// $Id: cron.php,v 1.1 2008/06/25 15:38:55 gotheric Exp $
-
 /**
  * ELYSIA_CRON
  * by Eric Berdondini (gotheric)
@@ -18,10 +16,6 @@
  * - ensure all shutdown hook functions launched by cron jobs are launched inside
  *   cron protection (ex: search_cron() will launch search_update_totals() in a
  *   shutdown hook).
- *
- * This file is cross-version (the same for D5, D6, D7).
- * (Needs the elysia_drupalconv.php)
- *
  */
 
 require_once('elysia_drupalconv.php');
@@ -38,35 +32,31 @@ $GLOBALS['elysia_cron_default_rules'] = array(
   '4 0 1 * *' => 'Once a month',
 );
 
-function elysia_cron_version() {
-  return 20110323;
-}
-
 /*******************************************************************************
  * DRUPAL HOOKS
  ******************************************************************************/
 
-function elysia_cron_menu($_dcr_maycache = true) {
+function elysia_cron_menu() {
   $items = array();
-  $items['admin/config/system/cron'] = array(
+  $items['admin/build/cron'] = array(
     'title' => 'Cron Settings',
     'description' => 'View and manage cron table',
     'page callback' => 'elysia_cron_admin_page',
     'access arguments' => array('administer elysia_cron'),
   );
-  $items['admin/config/system/cron/status'] = array(
+  $items['admin/build/cron/status'] = array(
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'title' => 'Status',
     'weight' => 1,
   );
-  $items['admin/config/system/cron/reset'] = array(
+  $items['admin/build/cron/reset'] = array(
     'type' => MENU_LOCAL_TASK,
     'title' => 'Reset statistics',
     'page callback' => 'elysia_cron_reset_page',
     'access arguments' => array('administer elysia_cron'),
     'weight' => 2,
   );
-  $items['admin/config/system/cron/settings'] = array(
+  $items['admin/build/cron/settings'] = array(
     'type' => MENU_LOCAL_TASK,
     'title' => 'Settings',
     'page callback' => 'drupal_get_form',
@@ -74,7 +64,7 @@ function elysia_cron_menu($_dcr_maycache = true) {
     'access arguments' => array('administer elysia_cron'),
     'weight' => 3,
   );
-  $items['admin/config/system/cron/execute'] = array(
+  $items['admin/build/cron/execute'] = array(
     'type' => MENU_CALLBACK,
     'page callback' => 'elysia_cron_execute_page',
     'access arguments' => array('administer elysia_cron'),
@@ -84,47 +74,17 @@ function elysia_cron_menu($_dcr_maycache = true) {
     'page callback' => 'elysia_cron_ping_page',
     'access callback' => TRUE,
   );
-  return _dcf_hook_menu($items, $_dcr_maycache);
-}
-
-if (EC_DRUPAL_VERSION >= 7) {
-  // Override standard cron page
-  function elysia_cron_menu_alter(&$items) {
-    $items['admin/config/system/cron'] = array(
-      'title' => 'Cron Settings',
-      'description' => 'View and manage cron table',
-      'page callback' => 'elysia_cron_admin_page',
-      'access arguments' => array('administer elysia_cron'),
-    );
-  }
+  return $items;
 }
 
-function elysia_cron_perm() { // For D5-D6
+function elysia_cron_perm() {
   return array('administer elysia_cron');
 }
-function elysia_cron_permission() { // For D7
-  return array(
-    'administer elysia_cron' => array('title' => t('Administer elysia cron'), 'description' => t('Perform changes to cron jobs timings, disable cron or single jobs and access cron execution statistics')),
-  );
-}
 
 function elysia_cron_boot() {
-  if (!_dcf_hook_boot('elysia_cron')) {
-    return;
-  }
-
-  if (EC_DRUPAL_VERSION < 7) {
-    global $conf;
-
-    // I need to set cron_semaphore always to false. That way standard drupal cron is always bypassed
-    $conf['cron_semaphore'] = false;
-  }
-}
-
-function elysia_cron_init() {
-  if (!_dcf_hook_init('elysia_cron')) {
-    return;
-  }
+  global $conf;
+  // I need to set cron_semaphore always to false. That way standard drupal cron is always bypassed
+  $conf['cron_semaphore'] = false;
 }
 
 /**
@@ -141,13 +101,11 @@ function elysia_cron_cron() {
 
   $result = elysia_cron_run($manual_run);
 
-  if (EC_DRUPAL_VERSION < 7) {
-    // I must check for cron_semaphore and delete it if set (is not always deleted by elysia_cron_run, and this situation is only when called by drupal cron, so a check here is right)
-    if (variable_get('cron_semaphore', false)) {
-      global $conf;
-      _ec_variable_del('cron_semaphore');
-      $conf['cron_semaphore'] = false;
-    }
+  // I must check for cron_semaphore and delete it if set (is not always deleted by elysia_cron_run, and this situation is only when called by drupal cron, so a check here is right)
+  if (variable_get('cron_semaphore', false)) {
+    global $conf;
+    _ec_variable_del('cron_semaphore');
+    $conf['cron_semaphore'] = false;
   }
 
   if ($manual_run) {
@@ -157,7 +115,7 @@ function elysia_cron_cron() {
     else {
       drupal_set_message(t('Cron run failed, disabled or nothing to do'));
     }
-    drupal_goto(_dcf_internal_path('admin/reports/status'));
+    drupal_goto('admin/reports/status');
   }
 
   exit();
@@ -169,7 +127,7 @@ function elysia_cron_cron() {
  * If it's not i'll set it and print a message
  */
 function elysia_cron_help($section, $arg = false) {
-  if ($section == _dcf_internal_path('admin/modules')) {
+  if ($section == 'admin/build/modules') {
     $min = drupal_module_get_min_weight('elysia_cron');
     $weight = drupal_module_get_weight('elysia_cron');
     if ($min <= $weight) {
@@ -187,7 +145,6 @@ function elysia_cron_help($section, $arg = false) {
 
 // Variables managed by _ec_variable method, because are setted during cron execution handling (with standard variable_set this will invalidate variable cache in EVERY cron clock)
 $GLOBALS['_ec_variables_allowed'] = array(
-  'elysia_cron_version', // Just for compatibility purpose during elysia_cron_update phase
   'elysia_cron_semaphore', 
   'elysia_cron_last_run',
   'elysia_cron_last_context', 
@@ -198,14 +155,9 @@ $GLOBALS['_ec_variables_allowed'] = array(
 function _ec_variable_init() {
   global $_ec_variables, $_ec_variables_allowed;
   $_ec_variables = array();
-  if (EC_DRUPAL_VERSION >= 7) {
-    $_ec_variables = array_map('unserialize', db_query("SELECT name, value FROM {variable} where name like '" . implode("' or name like '", $_ec_variables_allowed) . "'")->fetchAllKeyed());
-  }
-  else {
-    $result = db_query("select * from {variable} where name like '" . implode("' or name like '", $_ec_variables_allowed) . "'");
-    while ($variable = db_fetch_object($result)) {
-      $_ec_variables[$variable->name] = unserialize($variable->value);
-    }
+  $result = db_query("select * from {variable} where name like '" . implode("' or name like '", $_ec_variables_allowed) . "'");
+  while ($variable = db_fetch_object($result)) {
+    $_ec_variables[$variable->name] = unserialize($variable->value);
   }
 }
 
@@ -217,7 +169,7 @@ function _ec_variable_init() {
 function _ec_variable_get($name, $default) {
   global $_ec_variables, $_ec_variables_allowed;
   if (!in_array($name, $_ec_variables_allowed)) {
-    _dco_watchdog('cron', 'Wrong variable passed to _ec_variable_get: !var', array('!var' => $name), WATCHDOG_ERROR);
+    watchdog('cron', 'Wrong variable passed to _ec_variable_get: !var', array('!var' => $name), WATCHDOG_ERROR);
     return variable_get($name, $default);
   }
 
@@ -246,7 +198,7 @@ function _ec_variable_get($name, $default) {
 function _ec_variable_set($name, $value) {
   global $_ec_variables, $_ec_variables_allowed;
   if (!in_array($name, $_ec_variables_allowed)) {
-    _dco_watchdog('cron', 'Wrong variable passed to _ec_variable_set: !var', array('!var' => $name), WATCHDOG_ERROR);
+    watchdog('cron', 'Wrong variable passed to _ec_variable_set: !var', array('!var' => $name), WATCHDOG_ERROR);
     return variable_set($name, $value);
   }
 
@@ -254,20 +206,14 @@ function _ec_variable_set($name, $value) {
     _ec_variable_init();
   }
 
-  if (EC_DRUPAL_VERSION >= 7) {
-    db_merge('variable')->key(array('name' => $name))->fields(array('value' => serialize($value)))->execute();
-
+  if (!variable_get('elysia_cron_alternate_var_handler', false)) {
+    db_lock_table('variable');
+    db_query("DELETE FROM {variable} WHERE name = '%s'", $name);
+    db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, serialize($value));
+    db_unlock_tables();
   }
   else {
-    if (!variable_get('elysia_cron_alternate_var_handler', false)) {
-      db_lock_table('variable');
-      db_query("DELETE FROM {variable} WHERE name = '%s'", $name);
-      db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, serialize($value));
-      db_unlock_tables();
-    }
-    else {
-      db_query("REPLACE INTO {variable} (name, value) VALUES ('%s', '%s')", $name, serialize($value));
-    }
+    db_query("REPLACE INTO {variable} (name, value) VALUES ('%s', '%s')", $name, serialize($value));
   }
 
   $_ec_variables[$name] = $value;
@@ -281,7 +227,7 @@ function _ec_variable_set($name, $value) {
 function _ec_variable_del($name) {
   global $_ec_variables, $_ec_variables_allowed;
   if (!in_array($name, $_ec_variables_allowed)) {
-    _dco_watchdog('cron', 'Wrong variable passed to _ec_variable_del: !var', array('!var' => $name), WATCHDOG_ERROR);
+    watchdog('cron', 'Wrong variable passed to _ec_variable_del: !var', array('!var' => $name), WATCHDOG_ERROR);
     return variable_del($name);
   }
 
@@ -289,52 +235,44 @@ function _ec_variable_del($name) {
     _ec_variable_init();
   }
 
-  if (EC_DRUPAL_VERSION >= 7) {
-    db_delete('variable')->condition('name', $name)->execute();
-
+  if (!variable_get('elysia_cron_alternate_var_handler', false)) {
+    db_lock_table('variable');
+    db_query("DELETE FROM {variable} WHERE name = '%s'", $name);
+    db_unlock_tables();
   }
   else {
-    if (!variable_get('elysia_cron_alternate_var_handler', false)) {
-      db_lock_table('variable');
-      db_query("DELETE FROM {variable} WHERE name = '%s'", $name);
-      db_unlock_tables();
-    }
-    else {
-      db_query("DELETE FROM {variable} WHERE name = '%s'", $name);
-    }
+    db_query("DELETE FROM {variable} WHERE name = '%s'", $name);
   }
 
   unset($_ec_variables[$name]);
 }
 
-if (EC_DRUPAL_VERSION < 7) {
-  function _ec_semaphore_get($name = 'elysia_cron_semaphore', $timeout = 120) {
-    if (function_exists('elysia_cron_semaphore_get_alternative')) {
-      return elysia_cron_semaphore_get_alternative($name, $timeout);
-    }
+function _ec_semaphore_get($name = 'elysia_cron_semaphore', $timeout = 120) {
+  if (function_exists('elysia_cron_semaphore_get_alternative')) {
+    return elysia_cron_semaphore_get_alternative($name, $timeout);
+  }
 
-    db_lock_table('variable');
-    $semglob = db_result(db_query("select value from {variable} where name = '%s'", 'elysia_cron_semaphore'));
-    $semglob = $semglob ? unserialize($semglob) : false;
-
-    $stuck = $semglob && (time() - $semglob > $timeout);
-    if ($stuck || !$semglob) {
-      db_query("DELETE FROM {variable} WHERE name = '%s'", 'elysia_cron_semaphore');
-      db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", 'elysia_cron_semaphore', serialize(time()));
-      $semglob = false; // We must return TRUE
-    }
-    db_unlock_tables();
+  db_lock_table('variable');
+  $semglob = db_result(db_query("select value from {variable} where name = '%s'", 'elysia_cron_semaphore'));
+  $semglob = $semglob ? unserialize($semglob) : false;
 
-    if ($stuck) {
-      _dco_watchdog('cron', 'Global semaphore has been active for more than 2 minutes, probably stuck, reset.', array(), WATCHDOG_ERROR);
-    }
+  $stuck = $semglob && (time() - $semglob > $timeout);
+  if ($stuck || !$semglob) {
+    db_query("DELETE FROM {variable} WHERE name = '%s'", 'elysia_cron_semaphore');
+    db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", 'elysia_cron_semaphore', serialize(time()));
+    $semglob = false; // We must return TRUE
+  }
+  db_unlock_tables();
 
-    return !$semglob;
+  if ($stuck) {
+    watchdog('cron', 'Global semaphore has been active for more than 2 minutes, probably stuck, reset.', array(), WATCHDOG_ERROR);
   }
+
+  return !$semglob;
 }
 
 function _ec_get_name($name) {
-  $maxlen = EC_DRUPAL_VERSION >= 6 ? 120 : 40;
+  $maxlen = 120;
   if (strlen($name) < $maxlen) {
     return $name;
   }
@@ -347,48 +285,43 @@ function elysia_cron_set($name, $channel = false, $values = array()) {
     $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;
-      }
+  $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;
+  }
+  $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("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;
 
-      db_query("insert into {elysia_cron} (" . implode(', ', $iquery1) . ") values (" . implode(', ', $iquery2) . ")", $ivalues);
+    $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);
   }
 
   global $elysia_cron_db_cache;
@@ -404,12 +337,7 @@ function elysia_cron_get($name, $channel = false, $key, $default, $refresh = fal
   }
 
   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));
-    }
+    $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];
@@ -676,10 +604,8 @@ function elysia_cron_admin_page() {
   $output .= '<p>Global disable: <i>' . ($v ? '<span class="warn">YES</span>' : 'no') . '</i></p>';
   $output .= '<p>Last channel executed: <i>' . (($c = elysia_cron_last_channel()) ? $c : t('n/a')) . '</i></p>';
 
-  if (EC_DRUPAL_VERSION < 7) {
-    if (_ec_variable_get('elysia_cron_semaphore', 0)) {
-      $output .= '<p><span class="warn">Global semaphore active since ' . elysia_cron_date(_ec_variable_get('elysia_cron_semaphore', 0)) . '</span></p>';
-    }
+  if (_ec_variable_get('elysia_cron_semaphore', 0)) {
+    $output .= '<p><span class="warn">Global semaphore active since ' . elysia_cron_date(_ec_variable_get('elysia_cron_semaphore', 0)) . '</span></p>';
   }
 
   $running = '';
@@ -714,7 +640,7 @@ function elysia_cron_admin_page() {
           (!empty($conf['disabled']) ? '<strike>' . $job . '</strike>' : (empty($conf['running']) ? '<b>' . $job . '</b>' : '<b><u>' . $job . '</u></b> <small title="' . t('Running') . '">(R)</small>')) . (elysia_cron_should_run($conf) ? ' <small title="' . t('Waiting for execution') . '">(w)</small>' : ''),
           array(
             'data' => '<i>' . elysia_cron_description($job) . '</i> ' .
-          '[' . _dco_l(t('run'), _dcf_internal_path('admin/config/system/cron/execute/') . $job, array('attributes' => array('onclick' => 'return confirm("' . t('Force execution of !job?', array('!job' => $job)) . '");'))) . ']',
+          '[' . l(t('run'), 'admin/build/cron/execute/' . $job, array('attributes' => array('onclick' => 'return confirm("' . t('Force execution of !job?', array('!job' => $job)) . '");'))) . ']',
             'colspan' => 4,
           ),
         );
@@ -754,7 +680,7 @@ function elysia_cron_reset_page() {
   }
 
   drupal_set_message(t('Reset done.'));
-  drupal_goto(_dcf_internal_path('admin/config/system/cron'));
+  drupal_goto('admin/build/cron');
 }
 
 function elysia_cron_settings_form() {
@@ -872,19 +798,6 @@ EOT
     '#collapsed' => true,
   );
 
-  if (EC_DRUPAL_VERSION >= 7) {
-    $form['installation']['cron_safe_threshold'] = array(
-      '#type' => 'select',
-      '#title' => t('Run cron on visitor\'s requests, every'),
-      '#default_value' => variable_get('cron_safe_threshold', DRUPAL_CRON_DEFAULT_THRESHOLD),
-      '#description' => t('Setting a time here will enable the "poormanscron" method, which runs the Drupal cron operation using normal browser/page requests instead of having to set up a crontab to request the cron.php script. This approach requires that your site gets regular traffic/visitors in order to trigger the cron request.') . '<br />' .
-        t('This way is fine if you don\'t need a great control over job starting times and execution frequency.') . '<br />' .
-        t('If you need a fine grained control over cron timings use the crontab metod, as <a href="!cron_url">described in Drupal installation guide</a>.', array('!cron_url' => url('http://drupal.org/cron'))) . '<br />' .
-        t('If you have a very large site, or you need to execute some jobs very often (more than once an hour) refer to Elysia cron\'s INSTALL.TXT to improve main cron setup.'),
-      '#options' => array(0 => t('Never / Use external crontab')) + drupal_map_assoc(array(3600, 10800, 21600, 43200, 86400, 604800), 'format_interval'),
-    );
-  }
-
   $form['installation']['cron_key'] = array(
     '#title' => t('Cron key'),
     '#type' => 'textfield',
@@ -1105,10 +1018,7 @@ EOT
   return _dcr_form($form);
 }
 
-function theme_elysia_cron_settings_form($_dco_variables) {
-  extract(_dcf_theme_form($_dco_variables));
-  $form = &$variables['form'];
-
+function theme_elysia_cron_settings_form($form) {
   $output = '<script type="text/javascript"><!--' . "\n" .
     /*'function _ec_select(editid, select) { if (select.value == \'custom\') {'.
       '$ = jQuery; $(select).hide();$("#"+editid).show();$("#"+editid).focus();'.
@@ -1204,13 +1114,12 @@ function theme_elysia_cron_settings_form($_dco_variables) {
 
   $form['channels']['#children'] = $coutput;
 
-  return $output . drupal_render_children($form);
+  return $output . drupal_render(_dcr_form($form));
   //$form['channels'][] = array('#type' => 'markup', '#markup' => $output);
   //return drupal_render(_dcr_form($form));
 }
 
-function elysia_cron_settings_form_validate($_dco_form, &$_dco_form_state) {
-  extract(_dcf_form_validate($_dco_form, $_dco_form_state));
+function elysia_cron_settings_form_validate($form, &$form_state) {
   global $elysia_cron_settings;
 
   $script = $form_state['values']['elysia_cron_script'];
@@ -1230,8 +1139,7 @@ function elysia_cron_settings_form_validate($_dco_form, &$_dco_form_state) {
   }
 }
 
-function elysia_cron_settings_form_submit($_dco_form, &$_dco_form_state) {
-  extract(_dcf_form_validate($_dco_form, $_dco_form_state));
+function elysia_cron_settings_form_submit($form, &$form_state) {
   $form_values = $form_state['values'];
 
   $op = isset($form_values['op']) ? $form_values['op'] : '';
@@ -1334,7 +1242,7 @@ function elysia_cron_settings_form_submit($_dco_form, &$_dco_form_state) {
 }
 
 function elysia_cron_date($timestamp) {
-  return $timestamp > 0 ? format_date($timestamp, EC_DRUPAL_VERSION >= 7 ? 'short' : 'small') : t('n/a');
+  return $timestamp > 0 ? format_date($timestamp, 'small') : t('n/a');
   //return date(variable_get('date_format_short', 'm/d/Y - H:i'), $timestamp);
 }
 
@@ -1359,7 +1267,7 @@ function elysia_cron_run_form_submit($_dco_form, &$_dco_form_state) {
     drupal_set_message(t('Cron run failed.'), 'error');
   }
 
-  drupal_goto(_dcf_internal_path('admin/config/system/cron'));
+  drupal_goto('admin/build/cron');
 }
 
 function elysia_cron_execute_page($job = false) {
@@ -1367,7 +1275,7 @@ function elysia_cron_execute_page($job = false) {
 
   if (!$job) {
     drupal_set_message(t('No job specified'), 'error');
-    drupal_goto(_dcf_internal_path('admin/config/system/cron'));
+    drupal_goto('admin/build/cron');
   }
 
   $running = false;
@@ -1385,13 +1293,11 @@ function elysia_cron_execute_page($job = false) {
     $cron_completed = false;
     $cron_executing_job = $job;
 
-    if (EC_DRUPAL_VERSION < 7) {
-      // Some modules (feedapi, ipaper...) uses the internal "cron_semaphore" variable to detect
-      // start time of cron process. I'll set this only in memory for that purpose.
-      // (In normal drupal cron execution that is done by a variable_set just before this call,
-      // but i need to set this manually if drupal cron is bypassed)
-      $conf['cron_semaphore'] = time();
-    }
+    // Some modules (feedapi, ipaper...) uses the internal "cron_semaphore" variable to detect
+    // start time of cron process. I'll set this only in memory for that purpose.
+    // (In normal drupal cron execution that is done by a variable_set just before this call,
+    // but i need to set this manually if drupal cron is bypassed)
+    $conf['cron_semaphore'] = time();
 
     // Register shutdown callback
     register_shutdown_function('elysia_cron_execute_page_cleanup');
@@ -1399,17 +1305,15 @@ function elysia_cron_execute_page($job = false) {
     elysia_cron_initialize();
     elysia_cron_execute($job);
 
-    if (EC_DRUPAL_VERSION < 7) {
-      _ec_variable_del('cron_semaphore');
-      $conf['cron_semaphore'] = false;
-    }
+    _ec_variable_del('cron_semaphore');
+    $conf['cron_semaphore'] = false;
 
     $cron_completed = true;
 
     drupal_set_message(t('Job executed'));
   }
 
-  drupal_goto(_dcf_internal_path('admin/config/system/cron'));
+  drupal_goto('admin/build/cron');
 }
 
 function elysia_cron_execute_page_cleanup() {
@@ -1421,7 +1325,7 @@ function elysia_cron_execute_page_cleanup() {
 
   // See if the semaphore is still locked.
   if (elysia_cron_is_job_running($cron_executing_job)) {
-    _dco_watchdog('cron', 'Unexpected termination of cron job %job manually started, aborted.', array('%job' => $cron_executing_job), WATCHDOG_WARNING);
+    watchdog('cron', 'Unexpected termination of cron job %job manually started, aborted.', array('%job' => $cron_executing_job), WATCHDOG_WARNING);
 
     elysia_cron_set_job_running($cron_executing_job, 0);
   }
@@ -1532,7 +1436,6 @@ function elysia_cron_module_jobs() {
 }
 
 function elysia_cron_initialize($skipscript = false) {
-  elysia_cron_check_version_update();
 
   global $elysia_cron_settings, $elysia_cron_settings_by_channel;
   $elysia_cron_settings = array();
@@ -1603,11 +1506,6 @@ function elysia_cron_run($manual_run = false) {
     set_time_limit(variable_get('elysia_cron_time_limit', 240));
   }
 
-  // Prevent session information from being saved while cron is running.
-  if (EC_DRUPAL_VERSION >= 7) {
-    drupal_save_session(FALSE);
-  }
-
   // If DISABLED block the execution
   if (variable_get('elysia_cron_disabled', false)) {
     return;
@@ -1629,16 +1527,8 @@ function elysia_cron_run($manual_run = false) {
   _ec_variable_set('cron_last', time());
 
   $execute = true;
-  if (EC_DRUPAL_VERSION >= 7) {
-    if (!lock_acquire('cron', 240.0)) {
-      _dco_watchdog('cron', 'Attempting to re-run cron while it is already running.', array(), WATCHDOG_WARNING);
-      $execute = false;
-    }
-  }
-  else {
-    // Global Semaphore to avoid concurrent execution of cron preparation code
-    $execute = _ec_semaphore_get('elysia_cron_semaphore', 120);
-  }
+  // Global Semaphore to avoid concurrent execution of cron preparation code
+  $execute = _ec_semaphore_get('elysia_cron_semaphore', 120);
 
   // Force the current user to anonymous to ensure consistent permissions on
   // cron runs (only if run by interface)
@@ -1647,22 +1537,7 @@ function elysia_cron_run($manual_run = false) {
     $GLOBALS['user'] = drupal_anonymous_user();
   }
 
-  if (EC_DRUPAL_VERSION >= 7) {
-    // D7 Queue processing
-    // Grab the defined cron queues (even if execute = false)
-    $queues = module_invoke_all('cron_queue_info');
-    drupal_alter('cron_queue_info', $queues);
-  }
-
   if ($execute) {
-    if (EC_DRUPAL_VERSION >= 7) {
-      // D7 Queue processing
-      // Make sure every queue exists. There is no harm in trying to recreate an
-      // existing queue.
-      foreach ($queues as $queue_name => $info) {
-        DrupalQueue::get($queue_name)->createQueue();
-      }
-    }
 
     elysia_cron_initialize();
     global $elysia_cron_settings, $elysia_cron_settings_by_channel, $elysia_cron_current_channel, $cron_completed, $cron_completed_time;
@@ -1683,7 +1558,7 @@ function elysia_cron_run($manual_run = false) {
         elysia_cron_set_channel_running($channels[$j], 0);
         $last_job = elysia_cron_execute_aborted($channels[$j]);
         unset($sem);
-        _dco_watchdog('cron', 'Cron channel (%channel) has been running for more than an %stuck_time secs and is most likely stuck. Last job executed: %job', array('%channel' => $channels[$j], '%stuck_time' => $stuck_time, '%job' => $last_job), WATCHDOG_ERROR);
+        watchdog('cron', 'Cron channel (%channel) has been running for more than an %stuck_time secs and is most likely stuck. Last job executed: %job', array('%channel' => $channels[$j], '%stuck_time' => $stuck_time, '%job' => $last_job), WATCHDOG_ERROR);
       }
       if (empty($sem) && !$elysia_cron_settings_by_channel[$channels[$j]]['#data']['disabled'] && time() - $elysia_cron_settings_by_channel[$channels[$j]]['#data']['last_run'] > 60) {
         $jobs = elysia_cron_active_jobs($channels[$j]);
@@ -1701,7 +1576,7 @@ function elysia_cron_run($manual_run = false) {
       elysia_cron_set_last_channel($elysia_cron_current_channel);
 
       if (variable_get('elysia_cron_debug_messages', 0)) {
-        _dco_watchdog('cron', 'Cron channel %channel run started.', array('%channel' => $elysia_cron_current_channel), WATCHDOG_NOTICE);
+        watchdog('cron', 'Cron channel %channel run started.', array('%channel' => $elysia_cron_current_channel), WATCHDOG_NOTICE);
       }
 
       // Register shutdown callback
@@ -1713,24 +1588,22 @@ function elysia_cron_run($manual_run = false) {
       ));
 
       // Now I can unlock cron semaphore
-      if (EC_DRUPAL_VERSION < 7) {
         _ec_variable_del('elysia_cron_semaphore');
 
-        // Some modules (feedapi, ipaper...) uses the internal "cron_semaphore" variable to detect
-        // start time of cron process. I'll set this only in memory for that purpose.
-        // (In normal drupal cron execution that is done by a variable_set just before this call,
-        // but i need to set this manually if drupal cron is bypassed)
-        $conf['cron_semaphore'] = time();
-      }
+      // Some modules (feedapi, ipaper...) uses the internal "cron_semaphore" variable to detect
+      // start time of cron process. I'll set this only in memory for that purpose.
+      // (In normal drupal cron execution that is done by a variable_set just before this call,
+      // but i need to set this manually if drupal cron is bypassed)
+      $conf['cron_semaphore'] = time();
 
       foreach ($jobs as $job) {
         $job_running = false;
         if (elysia_cron_is_job_running($job)) {
           if (time() - elysia_cron_get_job_last_run($job, 0) > variable_get('elysia_cron_stuck_time', 3600)) {
-            _dco_watchdog('cron', 'Job %job is already running, but is probably stuck, so i consider it as terminated', array('%job' => $job), WATCHDOG_NOTICE);
+            watchdog('cron', 'Job %job is already running, but is probably stuck, so i consider it as terminated', array('%job' => $job), WATCHDOG_NOTICE);
           }
           else {
-            _dco_watchdog('cron', 'Job %job is already running', array('%job' => $job), WATCHDOG_NOTICE);
+            watchdog('cron', 'Job %job is already running', array('%job' => $job), WATCHDOG_NOTICE);
             $job_running = true;
           }
         }
@@ -1749,45 +1622,21 @@ function elysia_cron_run($manual_run = false) {
     }
     else {
       // No jobs should be executed, i must unlock cron semaphore
-      if (EC_DRUPAL_VERSION < 7) {
-        _ec_variable_del('elysia_cron_semaphore');
-      }
+      _ec_variable_del('elysia_cron_semaphore');
 
       if (variable_get('elysia_cron_debug_messages', 0)) {
-        _dco_watchdog('cron', 'No channels ready to be executed, skipping cron.', array(), WATCHDOG_NOTICE);
+        watchdog('cron', 'No channels ready to be executed, skipping cron.', array(), WATCHDOG_NOTICE);
       }
     }
 
     // Release cron lock.
-    if (EC_DRUPAL_VERSION >= 7) {
-      lock_release('cron');
-
-    }
-    else {
-      _ec_variable_del('cron_semaphore');
-      $conf['cron_semaphore'] = false;
-    }
-  }
-
-  if (EC_DRUPAL_VERSION >= 7) {
-    // D7 Queue processing
-    foreach ($queues as $queue_name => $info) {
-      $function = $info['worker callback'];
-      $end = time() + (isset($info['time']) ? $info['time'] : 15);
-      $queue = DrupalQueue::get($queue_name);
-      while (time() < $end && ($item = $queue->claimItem())) {
-        $function($item->data);
-        $queue->deleteItem($item);
-      }
-    }
+    _ec_variable_del('cron_semaphore');
+    $conf['cron_semaphore'] = false;
   }
 
   if ($manual_run) {
     // Restore the user.
     $GLOBALS['user'] = $original_user;
-    if (EC_DRUPAL_VERSION >= 7) {
-      drupal_save_session(TRUE);
-    }
   }
 
   // Return TRUE so other functions can check if it did run successfully
@@ -1798,7 +1647,7 @@ function elysia_cron_execute($job) {
   global $elysia_cron_settings;
 
   if (variable_get('elysia_cron_debug_messages', 0)) {
-    _dco_watchdog('cron', 'Cron job %job started.', array('%job' => $job), WATCHDOG_NOTICE);
+    watchdog('cron', 'Cron job %job started.', array('%job' => $job), WATCHDOG_NOTICE);
   }
 
   $time = time();
@@ -1818,11 +1667,11 @@ function elysia_cron_execute($job) {
       call_user_func_array($elysia_cron_settings[$job]['callback'], $elysia_cron_settings[$job]['arguments']);
     }
     else {
-      _dco_watchdog('cron', 'Execution of ' . $job . ' failed, can\'t find function!', array(), WATCHDOG_ERROR);
+      watchdog('cron', 'Execution of ' . $job . ' failed, can\'t find function!', array(), WATCHDOG_ERROR);
     }
   }
   catch (Exception $e) {
-    _dco_watchdog('cron', 'Exception: ' . $e, array(), WATCHDOG_ERROR);
+    watchdog('cron', 'Exception: ' . $e, array(), WATCHDOG_ERROR);
     $exception = true;
     //TODO Manage it
   }
@@ -1839,7 +1688,7 @@ function elysia_cron_execute($job) {
   );
 
   if (variable_get('elysia_cron_debug_messages', 0)) {
-    _dco_watchdog('cron', 'Cron job %job ended.', array('%job' => $job), WATCHDOG_NOTICE);
+    watchdog('cron', 'Cron job %job ended.', array('%job' => $job), WATCHDOG_NOTICE);
   }
 }
 
@@ -1881,7 +1730,7 @@ function elysia_cron_cleanup() {
   // See if the semaphore is still locked.
   if (elysia_cron_is_channel_running($elysia_cron_current_channel)) {
     $last_job = elysia_cron_execute_aborted($elysia_cron_current_channel);
-    _dco_watchdog('cron', 'Unexpected termination of cron channel %channel, aborted. Last job executed: %job', array('%channel' => $elysia_cron_current_channel, '%job' => $last_job), WATCHDOG_WARNING);
+    watchdog('cron', 'Unexpected termination of cron channel %channel, aborted. Last job executed: %job', array('%channel' => $elysia_cron_current_channel, '%job' => $last_job), WATCHDOG_WARNING);
   }
 }
 
@@ -1896,7 +1745,7 @@ function elysia_cron_completed() {
   _ec_variable_set('cron_last', time());
 
   if (variable_get('elysia_cron_debug_messages', 0)) {
-    _dco_watchdog('cron', 'Cron channel %channel run completed.', array('%channel' => $elysia_cron_current_channel), WATCHDOG_NOTICE);
+    watchdog('cron', 'Cron channel %channel run completed.', array('%channel' => $elysia_cron_current_channel), WATCHDOG_NOTICE);
   }
 
   $stats = elysia_cron_get_channel_stats($elysia_cron_current_channel);
@@ -1982,8 +1831,7 @@ function elysia_cron_theme() {
  * You can theme this function to provide your description for cron functions, if they do not provide one.
  */
 function theme_elysia_cron_description($variables) {
-  extract(_dcf_theme_signature(array('job' => $variables)));
-  switch ($variables['job']) {
+  switch ($variables) {
     case 'search_cron':
       return 'Update search database index';
     case 'activitystream_cron':
diff --git a/elysia_cron_scheduler.inc b/elysia_cron_scheduler.inc
index 808ffda..b57f735 100644
--- a/elysia_cron_scheduler.inc
+++ b/elysia_cron_scheduler.inc
@@ -26,7 +26,7 @@ function _elysia_cron_next_run($conf) {
   );
 
   if (!preg_match('/^([0-9*,\/-]+)[ ]+([0-9*,\/-]+)[ ]+([0-9*,\/-]+)[ ]+([0-9*,\/-]+)[ ]+([0-9*,\/-]+)$/', $conf['rule'], $rules)) {
-    _dco_watchdog('cron', 'Invalid rule found: %rule', array('%rule' => $conf['rule']));
+    watchdog('cron', 'Invalid rule found: %rule', array('%rule' => $conf['rule']));
     return false;
   }
 
diff --git a/elysia_cron_scheduler_old.inc b/elysia_cron_scheduler_old.inc
deleted file mode 100644
index 21f6f6c..0000000
--- a/elysia_cron_scheduler_old.inc
+++ /dev/null
@@ -1,230 +0,0 @@
-<?php
-
-function elysia_cron_should_run($conf, $now = -1) {
-  if ($conf['disabled']) {
-    return false;
-  }
-
-  if ($now < 0) {
-    $now = time();
-  }
-
-  if ((!$conf['last_run']) || ($now - $conf['last_run'] > 365 * 86400)) {
-    return true;
-  }
-
-  if (!preg_match('/^([0-9*,\/-]+)[ ]+([0-9*,\/-]+)[ ]+([0-9*,\/-]+)[ ]+([0-9*,\/-]+)[ ]+([0-9*,\/-]+)$/', $conf['rule'], $rules)) {
-    _dco_watchdog('cron', 'Invalid rule found: %rule', array('%rule' => $conf['rule']));
-    return false;
-  }
-
-  $weekdayspec = ($rules[5] != '*');
-  $mondayspec = ($rules[3] != '*');
-
-  $rules[5] = _cronDecodeRule($rules[5], 0, 6);
-  $rules[4] = _cronDecodeRule($rules[4], 1, 12);
-  $rules[3] = _cronDecodeRule($rules[3], 1, 31);
-  $rules[2] = _cronDecodeRule($rules[2], 0, 23);
-  $rules[1] = _cronDecodeRule($rules[1], 0, 59);
-
-  $lastT = _cronT($conf['last_run'] + 30);
-  $nowT = _cronT($now);
-  $nowTDelta = $nowT - $lastT + ($lastT > $nowT ? 12 * 31 * 24 * 60 : 0);
-  $year = date('Y', $conf['last_run']);
-
-  if ($mondayspec || (!$mondayspec && !$weekdayspec)) {
-    $first = -1;
-    foreach ($rules[4] as $mon) {
-      foreach ($rules[3] as $d) {
-        if (checkdate($mon, $d, $year)) {
-          foreach ($rules[2] as $h) {
-            foreach ($rules[1] as $m) {
-              $t = _cronT($mon, $d, $h, $m);
-              //dprint("* ".$t." L:".$lastT);
-              if ($first < 0) {
-                $first = $t;
-              }
-              if ($t > $lastT) {
-                $nextT = $t;
-                break 4;
-              }
-            }
-          }
-        }
-      }
-    }
-    //dprint("R: ".$nextT);
-    if (!$nextT) {
-      $nextT = $first;
-    }
-
-    $nextTDelta = $nextT - $lastT + ($lastT > $nextT ? 12 * 31 * 24 * 60 : 0);
-
-    //dprint($nowT.' '.$nowTDelta.' '.$nextT.' '.$nextTDelta);
-    if ($nowTDelta >= $nextTDelta) {
-      return true;
-    }
-  }
-  if ($weekdayspec) {
-    foreach ($rules[4] as $mon) {
-      foreach (_cronMonDaysFromWeekDays($year, $mon, $rules[5]) as $d) {
-        foreach ($rules[2] as $h) {
-          foreach ($rules[1] as $m) {
-            $t = _cronT($mon, $d, $h, $m);
-            //dprint("* ".$t." L:".$lastT);
-            if ($t > $lastT) {
-              $nextT = $t;
-              break 4;
-            }
-          }
-        }
-      }
-    }
-    //dprint("R: ".$nextT);
-    if (!$nextT) {
-      //Must get the first of following year (if day_of_week is specified it's not the same of previous one)
-      foreach ($rules[4] as $mon) {
-        foreach (_cronMonDaysFromWeekDays($year + 1, $mon, $rules[5]) as $d) {
-          foreach ($rules[2] as $h) {
-            foreach ($rules[1] as $m) {
-              $nextT = _cronT($mon, $d, $h, $m);
-              break 4;
-            }
-          }
-        }
-      }
-    }
-
-    $nextTDelta = $nextT - $lastT + ($lastT > $nextT ? 12 * 31 * 24 * 60 : 0);
-
-    //dprint($nowT.' '.$nowTDelta.' '.$nextT.' '.$nextTDelta);
-    if ($nowTDelta >= $nextTDelta) {
-      return true;
-    }
-  }
-
-  return false;
-}
-
-// Used by elysia_cron_should_run
-function _cronT($time, $d = -1, $h = -1, $m = -1) {
-  if ($d < 0) {
-    return date('n', $time) * 31 * 24 * 60 + date('j', $time) * 24 * 60 + date('H', $time) * 60 + date('i', $time);
-  }
-  else {
-    return $time * 31 * 24 * 60 + $d * 24 * 60 + $h * 60 + $m;
-  }
-}
-
-// Used by elysia_cron_should_run
-function _cronMonDaysFromWeekDays($year, $mon, $weekdays) {
-  $result = array();
-  for ($i = 1; checkdate($mon, $i, $year); $i++) {
-    $w = date('w', mktime(12, 00, 00, $mon, $i, $year));
-    if (in_array($w, $weekdays)) {
-      $result[] = $i;
-    }
-  }
-  return $result;
-}
-
-// Used by elysia_cron_should_run
-function _cronDecodeRule($rule, $min, $max) {
-  if ($rule == '*') {
-    return range($min, $max);
-  }
-
-  $result = array();
-  foreach (explode(',', $rule) as $token) {
-    if (preg_match('/^([0-9]+)-([0-9]+)$/', $token, $r)) {
-      $result = array_merge($result, range($r[1], $r[2]));
-    }
-    elseif (preg_match('/^\*\/([0-9]+)$/', $token, $r)) {
-      for ($i = $min; $i <= $max; $i++) {
-        if ($i % $r[1] == 0) {
-          $result[] = $i;
-        }
-      }
-    }
-    elseif (is_numeric($token)) {
-      $result[] = $token;
-    }
-  }
-  return $result;
-}
-
-/*******************************************************************************
- * TESTS
- ******************************************************************************/
-
-function test_elysia_cron_should_run() {
-  dprint("Start test");
-  $start = microtime(true);
-  
-  //mktime: hr min sec mon day yr
-  dprint(" 1." . (false == elysia_cron_should_run(array('rule' => '0 12 * * *', 'last_run' => mktime(12, 0, 0, 1, 2, 2008)), mktime(12, 01, 0, 1, 2, 2008))));
-  dprint(" 2." . (false == elysia_cron_should_run(array('rule' => '0 12 * * *', 'last_run' => mktime(12, 0, 0, 1, 2, 2008)), mktime(15, 00, 0, 1, 2, 2008))));
-  dprint(" 3." . (false == elysia_cron_should_run(array('rule' => '0 12 * * *', 'last_run' => mktime(12, 0, 0, 1, 2, 2008)), mktime(11, 59, 0, 1, 3, 2008))));
-  dprint(" 4." . (true  == elysia_cron_should_run(array('rule' => '0 12 * * *', 'last_run' => mktime(12, 0, 0, 1, 2, 2008)), mktime(12, 00, 0, 1, 3, 2008))));
-  dprint(" 5." . (false == elysia_cron_should_run(array('rule' => '59 23 * * *', 'last_run' => mktime(23, 59, 0, 1, 2, 2008)), mktime(0, 00, 0, 1, 3, 2008))));
-  dprint(" 6." . (true  == elysia_cron_should_run(array('rule' => '59 23 * * *', 'last_run' => mktime(23, 59, 0, 1, 2, 2008)), mktime(23, 59, 0, 1, 3, 2008))));
-  dprint(" 7." . (true  == elysia_cron_should_run(array('rule' => '59 23 * * *', 'last_run' => mktime(23, 59, 0, 1, 2, 2008)), mktime(0, 00, 0, 1, 4, 2008))));
-  dprint(" 8." . (true  == elysia_cron_should_run(array('rule' => '59 23 * * *', 'last_run' => mktime(23, 58, 0, 1, 2, 2008)), mktime(23, 59, 0, 1, 2, 2008))));
-  dprint(" 9." . (true  == elysia_cron_should_run(array('rule' => '59 23 * * *', 'last_run' => mktime(23, 58, 0, 1, 2, 2008)), mktime(0, 0, 0, 1, 3, 2008))));
-  dprint("10." . (false == elysia_cron_should_run(array('rule' => '59 23 * * 0', 'last_run' => mktime(23, 58, 0, 1, 5, 2008)), mktime(23, 59, 0, 1, 5, 2008))));
-  dprint("11." . (false == elysia_cron_should_run(array('rule' => '59 23 * * 0', 'last_run' => mktime(23, 58, 0, 1, 5, 2008)), mktime(0, 0, 0, 1, 6, 2008))));
-  dprint("12." . (true  == elysia_cron_should_run(array('rule' => '59 23 * * 0', 'last_run' => mktime(23, 58, 0, 1, 5, 2008)), mktime(23, 59, 0, 1, 6, 2008))));
-  dprint("13." . (true  == elysia_cron_should_run(array('rule' => '59 23 * * 0', 'last_run' => mktime(23, 58, 0, 1, 5, 2008)), mktime(00, 00, 0, 1, 7, 2008))));
-  dprint("14." . (true  == elysia_cron_should_run(array('rule' => '29,59 23 * * 0', 'last_run' => mktime(23, 58, 0, 1, 5, 2008)), mktime(23, 29, 0, 1, 6, 2008))));
-  dprint("15." . (true  == elysia_cron_should_run(array('rule' => '29,59 23 * * 0', 'last_run' => mktime(23, 58, 0, 1, 5, 2008)), mktime(23, 59, 0, 1, 6, 2008))));
-  dprint("16." . (false == elysia_cron_should_run(array('rule' => '29,59 23 * * 0', 'last_run' => mktime(23, 58, 0, 1, 5, 2008)), mktime(23, 59, 0, 1, 5, 2008))));
-  dprint("17." . (true  == elysia_cron_should_run(array('rule' => '29,59 23 * * 0', 'last_run' => mktime(23, 58, 0, 1, 5, 2008)), mktime(23, 58, 0, 1, 6, 2008))));
-  dprint("18." . (false == elysia_cron_should_run(array('rule' => '29,59 23 * * 0', 'last_run' => mktime(23, 58, 0, 1, 5, 2008)), mktime(23, 28, 0, 1, 6, 2008))));
-  dprint("19." . (false == elysia_cron_should_run(array('rule' => '29,59 23 * * 0', 'last_run' => mktime(23, 28, 0, 1, 5, 2008)), mktime(23, 29, 0, 1, 5, 2008))));
-  dprint("20." . (false == elysia_cron_should_run(array('rule' => '29,59 23 * * 0', 'last_run' => mktime(23, 28, 0, 1, 5, 2008)), mktime(23, 30, 0, 1, 5, 2008))));
-  dprint("21." . (false == elysia_cron_should_run(array('rule' => '29,59 23 * * 0', 'last_run' => mktime(23, 28, 0, 1, 5, 2008)), mktime(23, 59, 0, 1, 5, 2008))));
-  dprint("22." . (true  == elysia_cron_should_run(array('rule' => '29,59 23 * * 0', 'last_run' => mktime(23, 28, 0, 1, 5, 2008)), mktime(23, 29, 0, 1, 6, 2008))));
-
-  dprint("23." . (false == elysia_cron_should_run(array('rule' => '29,59 23 * * 5', 'last_run' => mktime(23, 59, 0, 2, 22, 2008)), mktime(23, 59, 0, 2, 28, 2008))));
-  dprint("24." . (true  == elysia_cron_should_run(array('rule' => '29,59 23 * * 5', 'last_run' => mktime(23, 59, 0, 2, 22, 2008)), mktime(23, 59, 0, 2, 29, 2008))));
-  dprint("25." . (true  == elysia_cron_should_run(array('rule' => '29,59 23 * * 5', 'last_run' => mktime(23, 59, 0, 2, 22, 2008)), mktime(0, 0, 0, 3, 1, 2008))));
-
-  dprint("26." . (false == elysia_cron_should_run(array('rule' => '59 23 * * 3', 'last_run' => mktime(23, 59, 0, 12, 31, 2008)), mktime(0, 0, 0, 1, 1, 2009))));
-  dprint("27." . (false == elysia_cron_should_run(array('rule' => '59 23 * * 3', 'last_run' => mktime(23, 59, 0, 12, 31, 2008)), mktime(0, 0, 0, 1, 7, 2009))));
-  dprint("28." . (true  == elysia_cron_should_run(array('rule' => '59 23 * * 3', 'last_run' => mktime(23, 59, 0, 12, 31, 2008)), mktime(23, 59, 0, 1, 7, 2009))));
-
-  dprint("29." . (true  == elysia_cron_should_run(array('rule' => '59 23 * 2 5', 'last_run' => mktime(23, 59, 0, 2, 22, 2008)), mktime(23, 59, 0, 2, 29, 2008))));
-  dprint("30." . (true  == elysia_cron_should_run(array('rule' => '59 23 * 2 5', 'last_run' => mktime(23, 59, 0, 2, 22, 2008)), mktime(0, 0, 0, 3, 1, 2008))));
-  dprint("31." . (false == elysia_cron_should_run(array('rule' => '59 23 * 2 5', 'last_run' => mktime(23, 59, 0, 2, 29, 2008)), mktime(23, 59, 0, 3, 7, 2008))));
-  dprint("32." . (false == elysia_cron_should_run(array('rule' => '59 23 * 2 5', 'last_run' => mktime(23, 59, 0, 2, 29, 2008)), mktime(23, 58, 0, 2, 6, 2009))));
-  dprint("33." . (true  == elysia_cron_should_run(array('rule' => '59 23 * 2 5', 'last_run' => mktime(23, 59, 0, 2, 29, 2008)), mktime(23, 59, 0, 2, 6, 2009))));
-  dprint("34." . (true  == elysia_cron_should_run(array('rule' => '59 23 *' . '/10 * *', 'last_run' => mktime(23, 58, 0, 1, 10, 2008)), mktime(23, 59, 0, 1, 10, 2008))));
-  dprint("35." . (false == elysia_cron_should_run(array('rule' => '59 23 *' . '/10 * *', 'last_run' => mktime(23, 59, 0, 1, 10, 2008)), mktime(23, 59, 0, 1, 11, 2008))));
-  dprint("36." . (true  == elysia_cron_should_run(array('rule' => '59 23 *' . '/10 * *', 'last_run' => mktime(23, 59, 0, 1, 10, 2008)), mktime(23, 59, 0, 1, 20, 2008))));
-  dprint("37." . (true  == elysia_cron_should_run(array('rule' => '59 23 1-5,10-15 * *', 'last_run' => mktime(23, 59, 0, 1, 4, 2008)), mktime(23, 59, 0, 1, 5, 2008))));
-  dprint("38." . (true  == elysia_cron_should_run(array('rule' => '59 23 1-5,10-15 * *', 'last_run' => mktime(23, 59, 0, 1, 4, 2008)), mktime(23, 59, 0, 1, 6, 2008))));
-  dprint("39." . (false == elysia_cron_should_run(array('rule' => '59 23 1-5,10-15 * *', 'last_run' => mktime(23, 59, 0, 1, 5, 2008)), mktime(23, 59, 0, 1, 6, 2008))));
-  dprint("40." . (false == elysia_cron_should_run(array('rule' => '59 23 1-5,10-15 * *', 'last_run' => mktime(23, 59, 0, 1, 5, 2008)), mktime(23, 58, 0, 1, 10, 2008))));
-  dprint("41." . (true  == elysia_cron_should_run(array('rule' => '59 23 1-5,10-15 * *', 'last_run' => mktime(23, 59, 0, 1, 5, 2008)), mktime(23, 59, 0, 1, 10, 2008))));
-  dprint("42." . (true  == elysia_cron_should_run(array('rule' => '59 23 1-5,10-15 * *', 'last_run' => mktime(23, 59, 0, 1, 5, 2008)), mktime(23, 59, 0, 1, 16, 2008))));
-
-  dprint("43." . (true  == elysia_cron_should_run(array('rule' => '59 23 1-5 1 0', 'last_run' => mktime(23, 59, 0, 1, 4, 2008)), mktime(23, 59, 0, 1, 5, 2008))));
-  dprint("44." . (true  == elysia_cron_should_run(array('rule' => '59 23 1-5 1 0', 'last_run' => mktime(23, 59, 0, 1, 5, 2008)), mktime(23, 59, 0, 1, 6, 2008))));
-  dprint("45." . (false == elysia_cron_should_run(array('rule' => '59 23 1-5 1 0', 'last_run' => mktime(23, 59, 0, 1, 6, 2008)), mktime(23, 59, 0, 1, 7, 2008))));
-  dprint("46." . (true  == elysia_cron_should_run(array('rule' => '59 23 1-5 1 0', 'last_run' => mktime(23, 59, 0, 1, 6, 2008)), mktime(23, 59, 0, 1, 13, 2008))));
-  dprint("47." . (false == elysia_cron_should_run(array('rule' => '59 23 1-5 1 0', 'last_run' => mktime(23, 59, 0, 2, 4, 2008)), mktime(23, 59, 0, 2, 5, 2008))));
-  dprint("48." . (false == elysia_cron_should_run(array('rule' => '59 23 1-5 1 0', 'last_run' => mktime(23, 59, 0, 2, 5, 2008)), mktime(23, 59, 0, 2, 10, 2008))));
-  dprint("49." . (false == elysia_cron_should_run(array('rule' => '59 23 1-5 1 0', 'last_run' => mktime(23, 59, 0, 2, 10, 2008)), mktime(23, 59, 0, 2, 17, 2008))));
-
-  dprint("49." . (true  == elysia_cron_should_run(array('rule' => '* 0,1,2,3,4,5,6,7,8,18,19,20,21,22,23 * * *', 'last_run' => mktime(8, 58, 0, 2, 10, 2008)), mktime(8, 59, 0, 2, 10, 2008))));
-  dprint("50." . (false == elysia_cron_should_run(array('rule' => '* 0,1,2,3,4,5,6,7,8,18,19,20,21,22,23 * * *', 'last_run' => mktime(8, 59, 0, 2, 10, 2008)), mktime(9, 00, 0, 2, 10, 2008))));
-  dprint("51." . (false == elysia_cron_should_run(array('rule' => '* 0,1,2,3,4,5,6,7,8,18,19,20,21,22,23 * * *', 'last_run' => mktime(8, 59, 0, 2, 10, 2008)), mktime(17, 59, 0, 2, 10, 2008))));
-  dprint("52." . (true  == elysia_cron_should_run(array('rule' => '* 0,1,2,3,4,5,6,7,8,18,19,20,21,22,23 * * *', 'last_run' => mktime(8, 59, 0, 2, 10, 2008)), mktime(18, 00, 0, 2, 10, 2008))));
-  dprint("53." . (true  == elysia_cron_should_run(array('rule' => '* 0,1,2,3,4,5,6,7,8,18,19,20,21,22,23 * * *', 'last_run' => mktime(18, 00, 0, 2, 10, 2008)), mktime(18, 01, 0, 2, 10, 2008))));
-  dprint("54." . (true  == elysia_cron_should_run(array('rule' => '* 0,1,2,3,4,5,6,7,8,18,19,20,21,22,23 * * *', 'last_run' => mktime(18, 00, 0, 2, 10, 2008)), mktime(19, 0, 0, 2, 10, 2008))));
-  dprint("55." . (true  == elysia_cron_should_run(array('rule' => '* 0,1,2,3,4,5,6,7,8,18,19,20,21,22,23 * * *', 'last_run' => mktime(18, 00, 0, 2, 10, 2008)), mktime(9, 0, 0, 3, 10, 2008))));
-
-  dprint("End test (" . (microtime(true) - $start) . ")");
-}
-// Remove comment to run tests
-//test_elysia_cron_should_run();die();
diff --git a/elysia_cron_update.php b/elysia_cron_update.php
deleted file mode 100755
index fb5b4ea..0000000
--- a/elysia_cron_update.php
+++ /dev/null
@@ -1,292 +0,0 @@
-<?php
-
-/*******************************************************************************
- * ELYSIA CRON VERSION UPDATE
- ******************************************************************************/
-
-function elysia_cron_check_version_update() {
-  $ver = variable_get('elysia_cron_version', 0);
-  if ($ver < 20111012) {
-    $ver = _ec_variable_get('elysia_cron_version', 0);
-  }
-
-  if (!$ver || $ver < 20090218) {
-
-    $unchanged = array(
-      'elysia_cron_last_context',
-      'elysia_cron_last_run',
-      'elysia_cron_disabled',
-      'elysia_cron_semaphore',
-      'elysia_cron_key',
-      'elysia_cron_allowed_hosts',
-      'elysia_cron_default_rule',
-      'elysia_cron_script',
-      'elysia_cron_runtime_replacement',
-      'elysia_cron_version',
-    );
-
-    $rs = db_query('select * from {variable} where name like "elysia_cron_%%"');
-    while ($v = db_fetch_object($rs)) {
-      if (!in_array($v->name, $unchanged)) {
-        $vn = false;
-        if (preg_match('/^elysia_cron_ctx_(.*)_(running|disabled|last_run|last_aborted|abort_count|execution_count|last_execution_time|avg_execution_time|max_execution_time|last_shutdown_time|last_abort_function)/', $v->name, $r)) {
-          switch ($r[2]) {
-            case 'running':
-              $vn = 'ecc_' . _ec_get_name($r[1]) . '_r';
-              break;
-            case 'disabled':
-              $vn = 'ecc_' . _ec_get_name($r[1]) . '_d';
-              break;
-            case 'last_run':
-              $vn = 'ecc_' . _ec_get_name($r[1]) . '_lr';
-              break;
-            case 'last_aborted':
-              $vn = 'ecc_' . _ec_get_name($r[1]) . '_la';
-              break;
-            case 'abort_count':
-              $vn = 'ecc_' . _ec_get_name($r[1]) . '_ac';
-              break;
-            case 'execution_count':
-              $vn = 'ecc_' . _ec_get_name($r[1]) . '_ec';
-              break;
-            case 'last_execution_time':
-              $vn = 'ecc_' . _ec_get_name($r[1]) . '_let';
-              break;
-            case 'avg_execution_time':
-              $vn = 'ecc_' . _ec_get_name($r[1]) . '_aet';
-              break;
-            case 'max_execution_time':
-              $vn = 'ecc_' . _ec_get_name($r[1]) . '_met';
-              break;
-            case 'last_shutdown_time':
-              $vn = 'ecc_' . _ec_get_name($r[1]) . '_lst';
-              break;
-            case 'last_abort_function':
-              $vn = 'ecc_' . _ec_get_name($r[1]) . '_laf';
-              break;
-          }
-        }
-        elseif (preg_match('/^elysia_cron_(.*)_(rule|disabled|context|running|last_run|last_execution_time|execution_count|avg_execution_time|max_execution_time)/', $v->name, $r)) {
-          switch ($r[2]) {
-            case 'rule':
-              $vn = 'ec_' . _ec_get_name($r[1]) . '_rul';
-              break;
-            case 'disabled':
-              $vn = 'ec_' . _ec_get_name($r[1]) . '_d';
-              break;
-            case 'context':
-              $vn = 'ec_' . _ec_get_name($r[1]) . '_c';
-              break;
-            case 'running':
-              $vn = 'ec_' . _ec_get_name($r[1]) . '_r';
-              break;
-            case 'last_run':
-              $vn = 'ec_' . _ec_get_name($r[1]) . '_lr';
-              break;
-            case 'last_execution_time':
-              $vn = 'ec_' . _ec_get_name($r[1]) . '_let';
-              break;
-            case 'execution_count':
-              $vn = 'ec_' . _ec_get_name($r[1]) . '_ec';
-              break;
-            case 'avg_execution_time':
-              $vn = 'ec_' . _ec_get_name($r[1]) . '_aet';
-              break;
-            case 'max_execution_time':
-              $vn = 'ec_' . _ec_get_name($r[1]) . '_met';
-              break;
-          }
-        }
-        if ($vn) {
-          variable_set($vn, unserialize($v->value));
-        }
-        else {
-          _dco_watchdog('cron', 'Error in update, cant convert %name (value: %value)', array('%name' => $v->name, '%value' => $v->value), WATCHDOG_ERROR);
-        }
-
-        variable_del($v->name);
-      }
-    }
-
-    variable_set('elysia_cron_version', 20090218);
-  }
-  if ($ver < 20090920) {
-    variable_set('elysia_cron_version', 20090920);
-
-  }
-  if ($ver < 20100507) {
-    if (EC_DRUPAL_VERSION >= 6)
-      // D6
-      drupal_install_schema('elysia_cron');
-
-    else {
-      // D5
-      switch ($GLOBALS['db_type']) {
-        case 'mysqli':
-        case 'mysql':
-          db_query("create table if not exists {elysia_cron} (
-            name varchar(120) not null,
-            disabled tinyint(1) not null default '0',
-            rule varchar(32),
-            weight int(11) not null default '0',
-            context varchar(32),
-            running int(11) not null default '0',
-            last_run int(11) not null default '0',
-            last_aborted tinyint(1) not null default '0',
-            abort_count int(11) not null default '0',
-            last_abort_function varchar(32),
-            last_execution_time int(11) not null default '0',
-            execution_count int(11) not null default '0',
-            avg_execution_time float(5,2) not null default '0',
-            max_execution_time int(11) not null default '0',
-            last_shutdown_time int(11) not null default '0',
-            primary key (name)
-          )");
-          break;
-        case 'pgsql':
-          db_query("create table {elysia_cron} (
-            name varchar(120) not null,
-            disabled smallint not null default '0',
-            rule varchar(32),
-            weight integer not null default '0',
-            context varchar(32),
-            running int not null default '0',
-            last_run integer not null default '0',
-            last_aborted smallint not null default '0',
-            abort_count integer not null default '0',
-            last_abort_function varchar(32),
-            last_execution_time integer not null default '0',
-            execution_count integer not null default '0',
-            avg_execution_time float not null default '0',
-            max_execution_time integer not null default '0',
-            last_shutdown_time integer not null default '0',
-            primary key (name)
-          )");
-      }
-    }
-
-    $rs = db_query('select * from {variable} where name like "ec_%%" or name like "ecc_%%"');
-    $data = array();
-    $todelete = array();
-    while ($v = db_fetch_object($rs)) {
-      $name = false;
-      if (preg_match('/^ecc_(.+)_(r|d|lr|la|ac|ec|let|aet|met|lst|laf)/', $v->name, $r)) {
-        $name = ':' . $r[1];
-      }
-      elseif (preg_match('/^ec_(.+)_(rul|d|c|w|r|lr|let|ec|aet|met)/', $v->name, $r)) {
-        $name = $r[1];
-      }
-      if ($name) {
-        if (!isset($data[$name])) {
-          $data[$name] = array('name' => $name);
-        }
-        switch ($r[2]) {
-          case 'r':
-            $f = 'running';
-            break;
-          case 'd':
-            $f = 'disabled';
-            break;
-          case 'rul':
-            $f = 'rule';
-            break;
-          case 'w':
-            $f = 'weight';
-            break;
-          case 'c':
-            $f = 'context';
-            break;
-          case 'lr':
-            $f = 'last_run';
-            break;
-          case 'la':
-            $f = 'last_aborted';
-            break;
-          case 'ac':
-            $f = 'abort_count';
-            break;
-          case 'laf':
-            $f = 'last_abort_function';
-            break;
-          case 'let':
-            $f = 'last_execution_time';
-            break;
-          case 'ec':
-            $f = 'execution_count';
-            break;
-          case 'aet':
-            $f = 'avg_execution_time';
-            break;
-          case 'met':
-            $f = 'max_execution_time';
-            break;
-          case 'lst':
-            $f = 'last_shutdown_time';
-            break;
-        }
-        $data[$name][$f] = unserialize($v->value);
-        $todelete[] = $v->name;
-      }
-    }
-
-    $ifields = array('disabled', 'weight', 'running', 'last_run', 'last_aborted', 'abort_count', 'last_execution_time', 'execution_count', 'avg_execution_time', 'max_execution_time', 'last_shutdown_time');
-    foreach ($data as $v) {
-      foreach ($ifields as $f) {
-        if (empty($v[$f])) {
-          $v[$f] = 0;
-        }
-      }
-      db_query("insert into {elysia_cron} (name, disabled, rule, weight, context, running, last_run, last_aborted, abort_count, last_abort_function, last_execution_time, execution_count, avg_execution_time, max_execution_time, last_shutdown_time)
-        values ('%s', %d, '%s', %d, '%s', %d, %d, %d, %d, '%s', %d, %d, %f, %d, %d)",
-        $v['name'], $v['disabled'], $v['rule'], $v['weight'], $v['context'], $v['running'], $v['last_run'], $v['last_aborted'], $v['abort_count'], $v['last_abort_function'], $v['last_execution_time'], $v['execution_count'], $v['avg_execution_time'], $v['max_execution_time'], $v['last_shutdown_time']
-      );
-    }
-
-    db_query("update {elysia_cron} set context = null where context = ''");
-    db_query("update {elysia_cron} set rule = null where rule = ''");
-
-    foreach ($todelete as $v) {
-      variable_del($v);
-      db_query("DELETE FROM {variable} WHERE name = '%s'", $v);
-    }
-
-    variable_set('elysia_cron_version', 20100507);
-
-    unset($GLOBALS['_ec_variables']);
-  }
-  if ($ver < 20110323) {
-    if (EC_DRUPAL_VERSION >= 7) {
-      // D7
-      // Must use "$v" for PHP5.3 running D6 version (detect the error even if it doesn't pass here)
-      db_change_field($v = 'elysia_cron', 'weight', 'weight', array('type' => 'int', 'not null' => FALSE));
-
-    }
-    elseif (EC_DRUPAL_VERSION >= 6) {
-      // D6
-      $ret = array();
-      db_change_field($ret, 'elysia_cron', 'weight', 'weight', array('type' => 'int', 'not null' => FALSE));
-    }
-    else {
-      // D5
-      db_query("alter table {elysia_cron} change weight weight int(11)");
-    }
-
-    variable_set('elysia_cron_version', 20110323);
-  }
-  // D7 VERSION FROM NOW ON...
-  
-  if ($ver < 20111007) {
-    $default_rules = variable_get('elysia_cron_default_rules', $GLOBALS['elysia_cron_default_rules']);
-    if (!empty($default_rules['*/6 * * * *']) && $default_rules['*/6 * * * *'] == 'Every 6 hours') {
-      unset($default_rules['*/6 * * * *']);
-      $default_rules['0 */6 * * *'] = 'Every 6 hours';
-      variable_set('elysia_cron_default_rules', $default_rules);
-    }
-    variable_set('elysia_cron_version', 20111007);
-  }
-
-  if ($ver < 20111012) {
-    // I only need to rebuild variable cache, so i just set the new version
-    variable_set('elysia_cron_version', 20111012);
-  }
-}
diff --git a/elysia_drupalconv.php b/elysia_drupalconv.php
index 2e63bd7..6b278c0 100755
--- a/elysia_drupalconv.php
+++ b/elysia_drupalconv.php
@@ -1,26 +1,5 @@
 <?php
 
-define('EC_DRUPAL_VERSION', 6);
-
-/***************************************************************
- * D6 VERSION 
- ***************************************************************/
-
-function _dcf_hook_boot($module) {
-  return true;
-}
-
-function _dcf_hook_init($module) {
-  return true;
-}
-
-function _dcf_hook_menu($items, $maycache) {
-  $new_items = array();
-  foreach ($items as $k => $v)
-    $new_items[_dcf_internal_path($k)] = $v;
-  return $new_items;
-}
-
 function _dcf_convert_render_array(&$a) {
   if (!empty($a['#markup'])) {
     $a['#value'] = $a['#markup'];
@@ -49,34 +28,10 @@ function _dcr_form(&$form) {
   return $form;
 }
 
-function _dcf_internal_path($path) {
-  return str_replace(
-    array( 'admin/config/system/cron', 'admin/modules' ),
-    array( 'admin/build/cron', 'admin/build/modules' ),
-    $path
-  );
-}
-  
-function _dco_watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL) { // WARN d7 changed WATCHDOG_ costants
-  return watchdog($type, $message, $variables, $severity, $link);
-}
-
-function _dco_l($text, $path, array $options = array()) {
-  return l($text, $path, $options);
-}
-
-function _dcf_form_validate(&$form, &$form_state) {
-  return array('form' => &$form, 'form_state' => &$form_state);
-}
-
 function _dco_theme($name, $args) {
   return call_user_func_array('theme', array_merge(array($name), array_values($args)));
 }
 
-function _dcf_theme_signature($args) {
-  return array( 'variables' => $args );
-}
-
 function _dcr_hook_theme($specs) {
   foreach ($specs as $k => $v) {
     if (!empty($v['variables'])) {
@@ -91,18 +46,6 @@ function _dcr_hook_theme($specs) {
   return $specs;
 }
 
-function _dcf_theme_form(&$args) {
-  return array( 'variables' => array( 'form' => $args ) );
-}
-
-/***************************************************************
- * D6 MISSING FUNCTIONS 
- ***************************************************************/
-
-function drupal_render_children($form) {
-  return drupal_render(_dcr_form($form));
-}
-
 /***************************************************************
  * D6 EXTRA FUNCTIONS 
  ***************************************************************/
