diff --git a/delegator/delegator.admin.inc b/delegator/delegator.admin.inc
index 4333296928f3efdb487989e7be84f295535ef48b..c8de2557f94c4e7a7b16bb6e4bf3a491da9bf576 100644
--- a/delegator/delegator.admin.inc
+++ b/delegator/delegator.admin.inc
@@ -780,7 +780,7 @@ function delegator_admin_list_form_submit($form, &$form_state) {
       // @todo -- do we need to clear the handler weight here?
     }
     // Otherwise, check to see if it has moved and, if so, update the weight.
-    elseif ($info['weight'] != $form_state['task_handlers'][$id]->weight) {
+    elseif ($info['weight'] != isset($form_state['task_handlers']) && $form_state['task_handlers'][$id]->weight) {
       // Theoretically we could only do this for in code objects, but since our
       // load mechanism checks for all, this is less database work.
       delegator_update_task_handler_weight($form_state['task_handlers'][$id], $info['weight']);
@@ -894,6 +894,9 @@ function delegator_admin_list_form_action_clone($form, &$form_state, $id, $actio
   // Get the next weight from the form
   $handler->weight = delegator_admin_update_weights($form_state);
 
+  $handler->export_type = EXPORT_IN_DATABASE;
+  $handler->type = t('Normal');
+
   // Generate a unique name. Unlike most named objects, we don't let people choose
   // names for task handlers because they mostly don't make sense.
   $base = $form_state['task']['name'];
diff --git a/delegator/delegator.module b/delegator/delegator.module
index 46a92d61b6a30564e711c844ca57aef9f5425bce..8a1fe8e508bd4d4355b9a81bb43dc045681db3ef 100644
--- a/delegator/delegator.module
+++ b/delegator/delegator.module
@@ -263,8 +263,13 @@ function delegator_load_task_handlers($task, $subtask_id = NULL, $default_handle
   $defaults = isset($default_handlers) ? $default_handlers : delegator_get_default_task_handlers($task, $subtask_id);
   foreach ($defaults as $name => $default) {
     $result = delegator_compare_task_handlers($handlers, $defaults, $name);
+
     if ($result) {
       $handlers[$name] = $result;
+      // Ensure task and subtask are correct, because it's easy to change task
+      // names when editing a default and fail to do it on the associated handlers.
+      $result->task = $task['name'];
+      $result->subtask = $subtask_id;
     }
   }
 
diff --git a/includes/context.inc b/includes/context.inc
index 3348c5e8b06e26f27eeef290e98da02404f83cd5..a2b329cb405cb907ac3587de4334d1d37e5d131c 100644
--- a/includes/context.inc
+++ b/includes/context.inc
@@ -160,8 +160,8 @@ class ctools_context_required {
     // Due to a bug, some contexts got recorded with an id of 0. This will
     // convert them to the correct ID allowing for some earlier panels
     // to continue to work.
-    if (!empty($context) && $context[strlen($context) - 1] == 0) {
-      $context[strlen($context) -1 ] = 1;
+    if (!empty($context) && $context[strlen($context) - 1] === '0') {\
+      $context[strlen($context) - 1] = 1;
     }
 
     if (empty($context) || empty($contexts[$context])) {
@@ -601,6 +601,10 @@ function ctools_context_keyword_substitute($string, $keywords, $contexts) {
  * are unique in the final list.
  */
 function ctools_context_id($context, $type = 'context') {
+  if (!$context['id']) {
+    $context['id'] = 1;
+  }
+
   return $type . '_' . $context['name'] . '_' . $context['id'];
 }
 
@@ -616,7 +620,6 @@ function ctools_context_id($context, $type = 'context') {
  */
 function ctools_context_next_id($objects, $name) {
   // Figure out which instance of this argument we're creating
-  $id = 0;
   if (!$objects) {
     return $id;
   }