diff --git a/imagefield_zip.ahah.inc b/imagefield_zip.ahah.inc
index 63e7aef..051d322 100644
--- a/imagefield_zip.ahah.inc
+++ b/imagefield_zip.ahah.inc
@@ -17,8 +17,7 @@ function imagefield_zip_js($type_name, $field_name) {
   if ($file = file_save_upload($field_name .'_zip', $validators)) {
     // Extract all files.
     $extracted = imagefield_zip_extract($file->filepath);
-    if (! empty($extracted)) {
-      watchdog('imagefield_zip', "Unpacked " . $file->filepath, array(), 'info');
+    if (!empty($extracted)) {
       // Only select valid image files
       $images = array_filter($extracted, '_imagefield_zip_is_archived_image');
     }
@@ -101,13 +100,14 @@ function _imagefield_zip_js($type_name, $field_name, $files) {
     if (!isset($field_element[$field_name][$delta]) || empty($field_element[$field_name][$delta]['#default_value'])) {
       $delta_element = $widget_function($built_form, $built_form_state, $field, array(), $delta);
 
-      if ($file = _imagefield_zip_save_file($file->filepath, $delta_element['#upload_validators'], $dest)) {
+      if ($file = field_file_save_file($file->filepath, $delta_element['#upload_validators'], $dest)) {
         // Set the default value of the widget to the extracted file.
         // Element requires #field_name and #type_name to be set
         // or it triggers PHP notices later on within content.module.
         $delta_element['#field_name'] = $field_name;
         $delta_element['#type_name'] = $type_name;
         $delta_element['#delta'] = $delta;
+        $delta_element['#array_parents'][] = $field_name;
 
         $delta_element['#default_value'] = filefield_widget_value($delta_element, (array) $file);
         // We add a div around the new content to tell AHAH to let this fade in.
@@ -132,6 +132,8 @@ function _imagefield_zip_js($type_name, $field_name, $files) {
       $file = next($files);
     }
   }
+  $field_element['#programmed'] = FALSE;
+  $field_element['#tree'] = FALSE;
 
   // Add the new element at the right place in the form.
   if (module_exists('fieldgroup') && ($group_name = _fieldgroup_field_get_group($type_name, $field_name))) {
@@ -160,89 +162,21 @@ function _imagefield_zip_js($type_name, $field_name, $files) {
   // either "Upload" or "Delete") yet. Which in turn causes it not to attach
   // AHAH behaviours after replacing the element. So we need to tell it first.
   $javascript = drupal_add_js(NULL, NULL);
+  $id = 'edit-' . str_replace('_', '-', $field_name) . '-upload';
   if (isset($javascript['setting'])) {
     $output .= '<script type="text/javascript">jQuery.extend(Drupal.settings, '. drupal_to_js(call_user_func_array('array_merge_recursive', $javascript['setting'])) .');</script>';
   }
 
+  // Destory the orginal zip upload form and replace it with the clean clone.
+  $output .= '<script type="text/javascript">
+  _imagefield_zip_' . $field_name . '_cloned.insertAfter(_imagefield_zip_' . $field_name . '_real);
+  _imagefield_zip_' . $field_name . '_real.remove();
+  _imagefield_zip_' . $field_name . '_real = $("#' . $id . '");
+  _imagefield_zip_' . $field_name . '_cloned = _imagefield_zip_' . $field_name . '_real.clone(true);
+  </script>';
+
   // For some reason, file uploads don't like drupal_json() with its manual
   // setting of the text/javascript HTTP header. So use this one instead.
   $GLOBALS['devel_shutdown'] = false;
   return $output;
 }
-
-function _imagefield_zip_save_file($filepath, $validators = array(), $dest = false, $replace = FILE_EXISTS_RENAME) {
-  global $user;
-
-  // Add in our check of the the file name length.
-  $validators['file_validate_name_length'] = array();
-
-  $extensions = '';
-  foreach ($user->roles as $rid => $name) {
-    $extensions .= ' '. variable_get("upload_extensions_$rid",
-    variable_get('upload_extensions_default', 'jpg jpeg gif png txt html doc xls pdf ppt pps odt ods odp'));
-  }
-
-  // Begin building file object.
-  $file = new stdClass();
-  $file->filename = file_munge_filename(trim(basename($filepath), '.'), $extensions);
-  $file->filepath = $filepath;
-  $file->filemime = file_get_mimetype($filepath);
-
-  // Rename potentially executable files, to help prevent exploits.
-  if (preg_match('/\.(php|pl|py|cgi|asp|js)$/i', $file->filename) && (substr($file->filename, -4) != '.txt')) {
-    $file->filemime = 'text/plain';
-    $file->filepath .= '.txt';
-    $file->filename .= '.txt';
-  }
-
-  // If the destination is not provided, or is not writable, then use the
-  // temporary directory.
-  if (empty($dest) || file_check_path($dest) === FALSE) {
-    $dest = file_directory_temp();
-  }
-
-  $file->destination = file_destination(file_create_path($dest .'/'. $file->filename), $replace);
-  $file->filesize = filesize($filepath);
-
-  // Call the validation functions.
-  $errors = array();
-  foreach ($validators as $function => $args) {
-    array_unshift($args, $file);
-    $errors = array_merge($errors, call_user_func_array($function, $args));
-  }
-
-  // Check for validation errors.
-  if (!empty($errors)) {
-    $message = t('The selected file %name could not be uploaded.', array('%name' => $file->filename));
-    if (count($errors) > 1) {
-      $message .= '<ul><li>'. implode('</li><li>', $errors) .'</li></ul>';
-    }
-    else {
-      $message .= ' '. array_pop($errors);
-    }
-
-    form_set_error($source, $message);
-    return 0;
-  }
-
-  $file->filepath = $file->destination;
-  if (!file_move($filepath, $file->filepath)) {
-    form_set_error($source, t('File upload error. Could not move uploaded file.'));
-    watchdog('file', 'Upload error. Could not move uploaded file %file to destination %destination.', array('%file' => $file->filename, '%destination' => $file->filepath));
-    return 0;
-  }
-
-  // If we made it this far it's safe to record this file in the database.
-  $file->uid = $user->uid;
-  $file->status = FILE_STATUS_TEMPORARY;
-  $file->timestamp = time();
-  drupal_write_record('files', $file);
-
-  // Let modules add additional properties to the yet barebone file object.
-  foreach (module_implements('file_insert') as $module) {
-    $function =  $module .'_file_insert';
-    $function($file);
-  }
-
-  return $file;
-}
\ No newline at end of file
diff --git a/imagefield_zip.module b/imagefield_zip.module
index a51231b..2374cf4 100644
--- a/imagefield_zip.module
+++ b/imagefield_zip.module
@@ -67,12 +67,10 @@ function imagefield_zip_extract($filepath) {
  */
 function imagefield_zip_form_alter(&$form, $form_state, $form_id) {
   if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id && ($type = content_types($form['#node']->type))) {
-    $form_added = false;
+    $form['#after_build'][] = '_imagefield_zip_form_after_build';
 
     foreach (_imagefield_zip_fields($type) as $field) {
-      if (_imagefield_zip_form($form, $field['field_name'], $form['#node'])) {
-        $form_added = true;
-      }
+      _imagefield_zip_form($form, $field['field_name'], $form['#node']);
     }
   }
 }
@@ -85,6 +83,64 @@ function _imagefield_zip_element_validate($element, &$form_state) {
 }
 
 /**
+* #after_build function to modify CCK fields
+*/
+function _imagefield_zip_form_after_build($form, &$form_state) {
+  $type = content_types($form['#node']->type);
+  foreach (_imagefield_zip_fields($type) as $field) {
+    $field_name = $field['field_name'];
+
+    // Move zip upload into fieldset if imagefield is in fieldset.
+    if (!isset($form[$field_name])) {
+      _imagefield_zip_cck_walker($form, $field_name, $form[$field_name .'_zip']);
+      unset($form[$field_name .'_zip']);
+    }
+
+    // Code below creates a clone of the upload field in javascript.
+    $id = 'edit-' . str_replace('_', '-', $field_name) . '-upload';
+    $v = '
+    <script type="text/javascript">
+    <!--//--><![CDATA[//><!--
+    _imagefield_zip_' . $field_name . '_real = $("#' . $id . '");
+    _imagefield_zip_' . $field_name . '_cloned = _imagefield_zip_' . $field_name . '_real.clone(true);
+    //--><!]]>
+    </script>
+    ';
+    $form['_markup_' . $field_name] = array(
+      '#type' => 'markup',
+      '#value' => $v,
+    );
+  }
+
+  return $form;
+}
+
+/**
+ * Recursively walk down the $form array looking for the CCK elements to modify
+ * @param $array array
+ *     the $form array or piece of the form array when called recursivly (must be passed by reference)
+ * @param $cck_field string
+ *    key name to look for.
+ * @param $zip_field array
+ *    form to insert into the fieldset.
+ * @see http://drupal.org/node/726282#comment-2848294
+ */
+function _imagefield_zip_cck_walker(&$array, $cck_field, $zip_field) {
+  foreach ($array as $key => &$value) {
+    if (is_array($value)) {
+      if (isset($value['#type']) && $value['#type'] == 'fieldset') {
+        // Call this function again recursively
+        _imagefield_zip_cck_walker($value, $cck_field, $zip_field);
+        continue;
+      }
+      if ($key == $cck_field) {
+        $array[$cck_field . '_zip'] = $zip_field;
+      }
+    }
+  }
+}
+
+/**
  * Implementation of hook_form().
  */
 function _imagefield_zip_form(&$form, $field_name, $node) {
@@ -94,7 +150,7 @@ function _imagefield_zip_form(&$form, $field_name, $node) {
     $form[$field_name .'_zip'] = array(
       '#weight' => intval($form[$field_name]['#weight']) + 0.01,
     );
-    $form[$field_name .'_zip']['upload'] = array(
+    $form[$field_name .'_zip'][$field_name . '_upload'] = array(
       '#type' => 'file',
       '#title' => t('Zip Upload'),
       '#name' => "files[{$field_name}_zip]",
@@ -105,7 +161,8 @@ function _imagefield_zip_form(&$form, $field_name, $node) {
       '#element_validate' => array('_imagefield_zip_element_validate'),
       //'#imagefield' => &$form[$field_name],
     );
-    $form[$field_name .'_zip']['button'] = array(
+
+    $form[$field_name .'_zip'][$field_name . '_button'] = array(
       '#type' => 'submit',
       '#value' => t('Upload'),
       '#process' => array('form_expand_ahah'),
@@ -116,16 +173,17 @@ function _imagefield_zip_form(&$form, $field_name, $node) {
         'method' => 'replace',
         'effect' => 'fade',
       ),
+      '#suffix' => '<br />',
     );
 
-    $form[$field_name]['#prefix'] = '<div id="'. $form[$field_name]['#field_name'] .'-ahah-wrapper">';
-    $form[$field_name]['#suffix'] = '</div>';
+    $form[$field_name]['#prefix'] .= '<div id="'. $form[$field_name]['#field_name'] .'-ahah-wrapper">';
+    $form[$field_name]['#suffix'] .= '</div>';
 
     return TRUE;
   }
 
   foreach (element_children($form) as $key) {
-    if (_imagefield_zip_form($form[$key], $field_name)) {
+    if (_imagefield_zip_form($form[$key], $field_name, $node)) {
       return TRUE;
     }
   }
@@ -158,7 +216,7 @@ function imagefield_zip_delete_file($file) {
   }
 }
 
-function imagefield_zip_is_valid_zip($file) {
+function imagefield_zip_is_valid_zip(&$file) {
   $errors = array();
   if (! function_exists('zip_open')) {
     watchdog('imagefield_zip', t('Required function zip_open was not available'), array(), 'error');
