diff --git a/node_import_update.module b/node_import_update.module
index 5505f7a..b6bac92 100644
--- a/node_import_update.module
+++ b/node_import_update.module
@@ -15,7 +15,8 @@ function node_import_update_menu() {
     'description' => t('Update current nodes at import.'),
     'page callback' => 'drupal_get_form',
     'page arguments' => array('node_import_update_settings_form'),
-    'access arguments' => array('administer node import update'),
+    'access callback' => 'user_access',
+    'access arguments' => array('administer imports'),
     'type' => MENU_NORMAL_ITEM,
   );
   return $items;
@@ -26,62 +27,146 @@ function node_import_update_menu() {
  * Implementation of hook_form_alter
  */
 function node_import_update_form_alter(&$form, $form_state, $form_id) {
-  // Check if we are importing
-  if (arg(2) == 'node_import') {
-    /**
-     * Set custom data
-     * These should  be defined in admin settings form for node import update
-     */
-     
-    $IMPORT_UNIQUE_ID_NAME   = variable_get('niu_id_field', 'title');  // Import field that holds the unique identifier
-    $IMPORT_UNIQUE_ID_TYPE   = variable_get('niu_id_field_type', FALSE); // Type of the unique identifier
-    $IMPORT_NTYPE            = variable_get('niu_content_type', 'page'); // Node type to be imported
-    $IMPORT_UPDATE_DATETIME  = variable_get('niu_update_date', FALSE); // Settting: update date/time value?
-
-
-    // Alter node edit form
-    if ($form_id == $IMPORT_NTYPE .'_node_form') {
-      // Determine the value and build the SQL query
-      // This switch should be changed to allow dinamicaly load the diferent ID types from the contrib .inc files
-      switch ($IMPORT_UNIQUE_ID_TYPE) {
-        case 'cck_field':
+  // Check if we are importing and on a node form
+  if (arg(2) == 'node_import' && $form_id == variable_get('niu_content_type', 'page') . '_node_form') {
+    // Variables from settings form.
+    $import_unique_id_name  = variable_get('niu_id_field', 'title');  // Import field that holds the unique identifier
+    $import_unique_id_type  = variable_get('niu_id_field_type', FALSE); // Type of the unique identifier
+    $import_update_datetime = variable_get('niu_update_date', FALSE); // Settting: update date/time value?
+    $import_node_type = variable_get('niu_content_type', 'page'); // Node type to be imported
+    // Determine the value and build the SQL query
+    // This switch should be changed to allow dinamicaly load the diferent ID types from the contrib .inc files
+    switch ($import_unique_id_type) {
+      case 'cck_field':
         // get unique id from cck fields
-        $unique_id_value = $form['#post']['cck:'.$IMPORT_UNIQUE_ID_NAME.':value'][0];
+        $unique_id_value = $form['#post']['cck:' . $import_unique_id_name . ':value'][0];
+        // Find out if this cck field is used more than once.
+        $field = content_fields($import_unique_id_name);
+        $types = array();
+        $result = db_query("SELECT nt.name, nt.type FROM {". content_instance_tablename() ."} nfi ".
+          "LEFT JOIN {node_type} nt ON nt.type = nfi.type_name ".
+          "WHERE nfi.field_name = '%s' ".
+          // Keep disabled modules out of table.
+          "AND nfi.widget_active = 1 ".
+          "ORDER BY nt.name ASC", $field['field_name']);
+        while ($type = db_fetch_array($result)) {
+          $content_type = content_types($type['type']);
+          $types[$content_type['url_str']] = $content_type['url_str'];
+        }
+        if (count($types) > 1 && array_search($import_node_type, $types)) {
+          // CCK fields used by multiple node types have their own table.
+          $cck_multi = TRUE;
+          $query = "SELECT c.nid, c.vid FROM {content_%s} c 
+            LEFT JOIN node n 
+            ON n.vid = c.vid 
+            AND n.nid = c.nid
+            WHERE (node.type in ('%s')) AND (c.%s_value = '%s')";
+        }
+        else {
+          // Only one cck field
+          $query = "SELECT c.nid, c.vid FROM {content_type_%s} c WHERE c.%s_value = '%s'";
+        }
+        break;
+      case 'uc_sku_field':
+        // get unique id from ubercart fields
+        $unique_id_value = $form['#post'][$import_unique_id_name];
         // build query
-        $query = 'SELECT c.nid, c.vid FROM {content_type_%s} c WHERE c.%s_value = "%s"';
-          break;
-        case 'uc_sku_field':
-       // get unique id from ubercart fields
-        $unique_id_value = $form['#post'][$IMPORT_UNIQUE_ID_NAME];
-       // build query
-       $query = 'SELECT n.nid, n.vid FROM {uc_products} u, {node} n WHERE u.nid = n.nid AND n.type = "%s" AND u.%s = "%s"';
-          break;
-        default:
+        $query = 'SELECT n.nid, n.vid FROM {uc_products} u, {node} n WHERE u.nid = n.nid AND n.type = "%s" AND u.%s = "%s"';
+        break;
+      default:
         // get unique id for node values
-        $unique_id_value = $form['#post'][$IMPORT_UNIQUE_ID_NAME];
+        $unique_id_value = $form['#post'][$import_unique_id_name];
         // build query
         $query = 'SELECT n.nid, n.vid FROM {node} n WHERE n.type = "%s" AND n.%s = "%s"';
+    }
+    // Check if we have a unique id
+    if ($unique_id_value) {
+      // execute query
+      if (!isset($cck_multi)) {
+        $row = db_fetch_array(db_query($query, $import_node_type, $import_unique_id_name, $unique_id_value));
       }
-
-      // Check if we have a unique id
-      if ($unique_id_value) {
-        // execute query
-        $row = db_fetch_array(db_query($query, $IMPORT_NTYPE, $IMPORT_UNIQUE_ID_NAME, $unique_id_value));
-
-        // Destroy so we don't pass an array on next iteration
-        unset($query);
-
-        // If already exists (non empty result)
-        if (!empty($row['nid'])) {
-          //drupal_set_message('update in effect!');
-
-          // Set nid and vid to that node
-          $form['nid']['#value']= intval($row['nid']);
-          $form['vid']['#value']= intval($row['vid']);
+      else {
+        $row = db_fetch_array(db_query($query, $import_unique_id_name, $import_node_type, $import_unique_id_name, $unique_id_value));
+      }
+      // Destroy so we don't pass an array on next iteration
+      unset($query);
+      // If already exists (non empty result)
+      if (!empty($row['nid'])) {
+        $node = node_load($row['nid']);
+        if (is_object($node)) {
+          // Find all the fields that are not being updated
+          foreach($form['#post'] as $key => $value) {
+            $node_field = NULL;
+            if (is_null($value) || (is_array($value) && !count($value))) {
+              // Set the empty value in the form from the node.
+              // Should the form_state values also get set here?
+              switch($key) {
+                case substr($key, 0, 4) == 'cck:':
+                  // cck field name
+                  $field_id = preg_replace("/cck:(.*?):.*/", '$1', $key);
+                  $value_label = preg_replace("/cck:.*?:(.*?)/", '$1', $key);
+                  // Lookup this value in the node
+                  if (property_exists($node, $field_id) && isset($node->{$field_id}[0]) && !empty($node->{$field_id}[0][$value_label])) {
+                    $field = content_fields($field_id);
+                    if ($field['type'] == 'datetime') {
+                      $date_format = date_limit_format($field['widget']['input_format'], $field['granularity']);
+                      $current = strtotime($node->{$field_id}[0][$value_label]);
+                      $datetime = date($date_format, $current);
+                      $form['#post'][$key][] = $node->{$field_id}[0][$value_label];
+                      $form['#post'][$field_id][0]['value']['date'] = $datetime;
+                    }
+                    elseif($field['type'] == 'text' && $field['widget']['type'] == 'optionwidgets_select') {
+                      $form['#post'][$key][] = $node->{$field_id}[0][$value_label];
+                      $form['#post'][$field_id][$value_label] = $node->{$field_id}[0][$value_label];
+                    }
+                    else {
+                      $form['#post'][$key] = $node->{$field_id}[0][$value_label];
+                      $form['#post'][$field_id] = $node->{$field_id};
+                    }
+                  }
+                  break;
+                case substr($key, 0, 6) == 'field_':
+                  //$field_id = $key;
+                  //$field = content_fields($field_id);
+                  break;
+                default:
+                  $field_id = $key;
+                  // Lookup this value in the node
+                  if (property_exists($node, $field_id) && !empty($node->{$field_id})) {
+                    $form['#post'][$field_id] = $node->{$field_id};
+                    $form['#post'][$key] = $node->{$field_id};
+                  }
+                  break;
+              }
+            }
+            else {
+              switch($key) {
+                case substr($key, 0, 4) == 'cck:':
+                  break;
+                case substr($key, 0, 6) == 'field_':
+                  $field_id = $key;
+                  $field = content_fields($field_id);
+                  if (is_array($field) && isset($field['type']) && $field['type'] == 'location') {
+                    // Location fields need special handling
+                    foreach($form['#post'][$field_id][0] as $loc_key => $loc_value) {
+                      if (is_null($loc_value)) {
+                       $form['#post'][$field_id][0][$loc_key] = $node->{$field_id}[0][$loc_key];
+                      }
+                    }
+                  }
+                  break;
+                default:
+                  break;
+              }
+            }
+          }
+          // Set nid and vid to this node
+          $form['nid']['#value'] = intval($row['nid']);
+          $form['vid']['#value'] = intval($row['vid']);
 
           // Set time to last updated
-          if ($IMPORT_UPDATE_DATETIME) {
-            $form['changed']['#value'] = time ();
+          if ($import_update_datetime) {
+            $form['changed']['#value'] = time();
           }
           else {
             // create timestamp from string date
@@ -102,7 +187,7 @@ function node_import_update_form_alter(&$form, $form_state, $form_id) {
  */
 function node_import_update_settings_form($form_state) {
   $form = array();
-  
+
   $form['niu_settings']['general'] = array(
      '#title'       => 'Node Import Update settings',
      '#type'        => 'fieldset',
@@ -182,4 +267,4 @@ function node_import_update_load_field_types() {
       $data['changed']['#value']= time ();
     }
   }
-} */
\ No newline at end of file
+} */
