diff --git a/supported/user_import.inc b/supported/user_import.inc
index 30af61e..ba0529f 100644
--- a/supported/user_import.inc
+++ b/supported/user_import.inc
@@ -20,73 +20,73 @@ function user_import_user_import_form_fieldset($import, $collapsed) {
 function user_import_user_import_after_save($settings, $account, $password, $fields, $updated, $update_setting_per_module) {
   if (!empty($settings['send_email']) && !$updated) {
 
-		$subscribed = isset($settings['subscribed']) ? $settings['subscribed'] : NULL;
-
-		_user_import_send_email($account,
-														$password,
-														$fields,
-														$settings['subject'],
-														$settings['message'],
-														$settings['message_format'],
-														$settings['message_css'],
-														$subscribed
-														);
-	}
+    $subscribed = isset($settings['subscribed']) ? $settings['subscribed'] : NULL;
+
+    _user_import_send_email($account,
+      $password,
+      $fields,
+      $settings['subject'],
+      $settings['message'],
+      $settings['message_format'],
+      $settings['message_css'],
+      $subscribed
+                           );
+  }
 }
 
 // Send email when account is created
 function _user_import_send_email($account, $password, $profile, $subject, $body, $format, $css, $subscribed) {
 
-    global $base_url;
-
-	  // All system mails need to specify the module and template key (mirrored from
-	  // hook_mail()) that the message they want to send comes from.
-	  $module = 'user_import';
-	  $key = 'welcome';
-
-	  // Specify 'to' and 'from' addresses.
-	  $to = $account->mail;
-	  $from = variable_get('site_mail', NULL);
-
-    $params = array(
-      '!username' => $account->name,
-      '!uid' => $account->uid,
-      '!site' => variable_get('site_name', 'drupal'),
-      '!login_url' => user_pass_reset_url($account),
-      '!password' => $password,
-      '!uri' => $base_url,
-      '!uri_brief' => drupal_substr($base_url, drupal_strlen('http://')),
-      '!mailto' => $account->mail,
-      '!date' => format_date(time()),
-      '!login_uri' => url('user', array('absolute' => TRUE)),
-      '!edit_uri' => url('user/'. $account->uid .'/edit', array('absolute' => TRUE)),
-      'subject' => $subject,
-      'body' => $body,
-      'email_format' => $format,
- 			'css' => $css,
-    );
+  global $base_url;
+
+  // All system mails need to specify the module and template key (mirrored from
+  // hook_mail()) that the message they want to send comes from.
+  $module = 'user_import';
+  $key = 'welcome';
+
+  // Specify 'to' and 'from' addresses.
+  $to = $account->mail;
+  $from = variable_get('site_mail', NULL);
+
+  $params = array(
+    '!username' => $account->name,
+    '!uid' => $account->uid,
+    '!site' => variable_get('site_name', 'drupal'),
+    '!login_url' => user_pass_reset_url($account),
+    '!password' => $password,
+    '!uri' => $base_url,
+    '!uri_brief' => drupal_substr($base_url, drupal_strlen('http://')),
+    '!mailto' => $account->mail,
+    '!date' => format_date(time()),
+    '!login_uri' => url('user', array('absolute' => TRUE)),
+    '!edit_uri' => url('user/'. $account->uid .'/edit', array('absolute' => TRUE)),
+    'subject' => $subject,
+    'body' => $body,
+    'email_format' => $format,
+    'css' => $css,
+  );
 
-    _user_import_publication_email($params, $account, $subscribed, $format);
+  _user_import_publication_email($params, $account, $subscribed, $format);
 
-    // import info to profile
-    if (module_exists('profile') && is_array($profile)) {
+  // import info to profile
+  if (module_exists('profile') && is_array($profile)) {
 
-      $profile_name = _user_import_profile('fid', 'name');
+    $profile_name = _user_import_profile('fid', 'name');
 
-      foreach ($profile_name as $fid => $field_name) {
-        $params['!' . $field_name] = $profile[$fid];
-      }
+    foreach ($profile_name as $fid => $field_name) {
+      $params['!' . $field_name] = $profile[$fid];
     }
+  }
 
-		$language = user_preferred_language($account);
+  $language = user_preferred_language($account);
 
-	  // Whether or not to automatically send the mail when drupal_mail() is
-	  // called. This defaults to TRUE, and is normally what you want unless you
-	  // need to do additional processing before drupal_mail_send() is called.
-	  $send = TRUE;
+  // Whether or not to automatically send the mail when drupal_mail() is
+  // called. This defaults to TRUE, and is normally what you want unless you
+  // need to do additional processing before drupal_mail_send() is called.
+  $send = TRUE;
 
-    $sent = drupal_mail($module, $key, $to, $language, $params, $from, $send);
-    return;
+  $sent = drupal_mail($module, $key, $to, $language, $params, $from, $send);
+  return;
 }
 
 /**
@@ -94,84 +94,84 @@ function _user_import_send_email($account, $password, $profile, $subject, $body,
  */
 function user_import_mail($key, &$message, $params) {
 
-	switch($key) {
-  	case 'welcome':
-		$message['subject'] = (empty($params['subject'])) ? _user_mail_text('register_admin_created_subject', $message['language'], $params) : strtr($params['subject'], $params);
-		$body = (empty($params['body'])) ? _user_mail_text('register_admin_created_body', $message['language'], $params) : strtr($params['body'], $params);
+  switch($key) {
+    case 'welcome':
+      $message['subject'] = (empty($params['subject'])) ? _user_mail_text('register_admin_created_subject', $message['language'], $params) : strtr($params['subject'], $params);
+      $body = (empty($params['body'])) ? _user_mail_text('register_admin_created_body', $message['language'], $params) : strtr($params['body'], $params);
 
-		if ($params['email_format'] == 1) {
-			$message['headers']['Content-Type'] = 'text/html; charset=UTF-8';
+      if ($params['email_format'] == 1) {
+        $message['headers']['Content-Type'] = 'text/html; charset=UTF-8';
 
-	    $body_head = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-	            <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
-	            <head>
-	            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />';
+        $body_head = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+              <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+              <head>
+              <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />';
 
-	    if (!empty($params['css'])) $body_head .= '<style type="text/css">' . check_plain($params['css']) . '</style>';
-	    $message['body'][] = $body_head . '</head><body>' . $body . '</body></html>';
-		}
-		else {
-      $message['body'][] = $body;
-		}
+        if (!empty($params['css'])) $body_head .= '<style type="text/css">' . check_plain($params['css']) . '</style>';
+        $message['body'][] = $body_head . '</head><body>' . $body . '</body></html>';
+      }
+      else {
+        $message['body'][] = $body;
+      }
 
-		break;
-	}
+      break;
+  }
 }
 
 function _user_import_edit_settings_fields(&$form, $import, $collapsed) {
 
   $form['optional'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Options'),
-      '#weight' => -85,
-      '#collapsible' => TRUE,
-      '#collapsed' => $collapsed,
+    '#type' => 'fieldset',
+    '#title' => t('Options'),
+    '#weight' => -85,
+    '#collapsible' => TRUE,
+    '#collapsed' => $collapsed,
   );
 
   $form['optional']['first_line_skip'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Ignore First Line'),
-      '#default_value' => isset($import['first_line_skip']) ? $import['first_line_skip'] : 0,
-      '#description' => t('If the first line is the names of the data columns, set to ignore first line.'),
+    '#type' => 'checkbox',
+    '#title' => t('Ignore First Line'),
+    '#default_value' => isset($import['first_line_skip']) ? $import['first_line_skip'] : 0,
+    '#description' => t('If the first line is the names of the data columns, set to ignore first line.'),
   );
   /**
    * @todo move contact options to a separate contact.inc support file
    */
   $form['optional']['contact'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Contact'),
-      '#default_value' => isset($import['contact']) ? $import['contact'] : 0,
-      '#description' => t("Set each user's personal contact form to 'allowed'."),
+    '#type' => 'checkbox',
+    '#title' => t('Contact'),
+    '#default_value' => isset($import['contact']) ? $import['contact'] : 0,
+    '#description' => t("Set each user's personal contact form to 'allowed'."),
   );
 
   $form['optional']['send_email'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Send Email'),
-      '#default_value' => isset($import['send_email']) ? $import['send_email'] : 0,
-      '#description' => t('Send email to users when their account is created.'),
+    '#type' => 'checkbox',
+    '#title' => t('Send Email'),
+    '#default_value' => isset($import['send_email']) ? $import['send_email'] : 0,
+    '#description' => t('Send email to users when their account is created.'),
   );
 
   $form['optional']['username_space'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Username Space'),
-      '#default_value' => isset($import['username_space']) ? $import['username_space'] : 0,
-      '#description' => t("Include spaces in usernames, e.g. 'John' + 'Smith' => 'John Smith'."),
+    '#type' => 'checkbox',
+    '#title' => t('Username Space'),
+    '#default_value' => isset($import['username_space']) ? $import['username_space'] : 0,
+    '#description' => t("Include spaces in usernames, e.g. 'John' + 'Smith' => 'John Smith'."),
   );
 
   $form['optional']['activate'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Activate Accounts'),
-      '#default_value' => isset($import['activate']) ? $import['activate'] : 0,
-      '#description' => t("User accounts will not be visible to other users until their owner logs in. Select this option to make all imported user accounts visible. <strong>Note - one time login links in welcome emails will no longer work if this option is enabled.</strong>"),
+    '#type' => 'checkbox',
+    '#title' => t('Activate Accounts'),
+    '#default_value' => isset($import['activate']) ? $import['activate'] : 0,
+    '#description' => t("User accounts will not be visible to other users until their owner logs in. Select this option to make all imported user accounts visible. <strong>Note - one time login links in welcome emails will no longer work if this option is enabled.</strong>"),
   );
 
-	$form['optional']['delimiter'] = array(
-	    '#type' => 'textfield',
-	    '#title' => t('File Delimiter'),
-	    '#size' => 4,
-	    '#default_value' => isset($import['delimiter']) ? $import['delimiter'] : ',',
-	    '#description' => t("The column delimiter for the file. Use '/t' for Tab."),
-	);
+  $form['optional']['delimiter'] = array(
+    '#type' => 'textfield',
+    '#title' => t('File Delimiter'),
+    '#size' => 4,
+    '#default_value' => isset($import['delimiter']) ? $import['delimiter'] : ',',
+    '#description' => t("The column delimiter for the file. Use '/t' for Tab."),
+  );
 
   return;
 }
@@ -181,82 +181,82 @@ function _user_import_edit_template_fields(&$form, $import) {
   // settings template update controls
   if (empty($import['name'])) {
 
-     // new settings template save controls
-
-      $form['save'] = array(
-          '#type' => 'fieldset',
-          '#title' => t('Save Settings'),
-          '#description' => t('Save settings for re-use on other imports.'),
-          '#weight' => 90,
-          '#collapsible' => TRUE,
-          '#collapsed' => FALSE,
-      );
-
-       $form['save']['name'] = array(
-          '#type' => 'textfield',
-          '#title' => t('Settings Name'),
-          '#size' => 26,
-          '#maxlength' => 25,
-          '#description' => t('Name to identify these settings by.'),
-      );
-
-      $form['save'][] = array(
-          '#type' => 'submit',
-          '#value' => t('Save'),
-          '#validate' => array('user_import_template_has_name_validate',
-                               'user_import_template_unique_name_validate',
-                               'user_import_edit_validate',
-                              ),
-          '#submit' => array('user_import_template_new_submit'),
-      );
+    // new settings template save controls
+
+    $form['save'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Save Settings'),
+      '#description' => t('Save settings for re-use on other imports.'),
+      '#weight' => 90,
+      '#collapsible' => TRUE,
+      '#collapsed' => FALSE,
+    );
+
+    $form['save']['name'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Settings Name'),
+      '#size' => 26,
+      '#maxlength' => 25,
+      '#description' => t('Name to identify these settings by.'),
+    );
+
+    $form['save'][] = array(
+      '#type' => 'submit',
+      '#value' => t('Save'),
+      '#validate' => array('user_import_template_has_name_validate',
+                   'user_import_template_unique_name_validate',
+                   'user_import_edit_validate',
+                          ),
+      '#submit' => array('user_import_template_new_submit'),
+    );
 
   }
   else {
 
-      $form['save'] = array(
-          '#type' => 'fieldset',
-          '#title' => t('Saved Settings'),
-          '#description' => t("If changes have neen made to the settings since they where last saved you can update the saved template, or save them as a new template."),
-          '#weight' => 90,
-          '#collapsible' => TRUE,
-          '#collapsed' => TRUE,
-      );
-
-      $form['#current_template'] = $import['name'];
-
-      $form['save']['update'] = array(
-          '#type' => 'fieldset',
-          '#title' => t('Update'),
-          '#description' => t("Update '%name' settings template", array('%name' => $import['name'])),
-      );
-
-      $form['save']['update']['submit'] = array(
-          '#type' => 'submit',
-          '#value' => t('Update'),
-          '#validate' => array('user_import_edit_validate'),
-          '#submit' => array('user_import_template_update_submit'),
-      );
-
-      $form['save']['new'] = array(
-          '#type' => 'fieldset',
-          '#title' => t('Create New'),
-          '#description' => t("Save as new settings template"),
-      );
-
-       $form['save']['new']['name'] = array(
-          '#type' => 'textfield',
-          '#title' => t('Save As New'),
-          '#size' => 30,
-          '#maxlength' => 25,
-          '#description' => t('Name to identify these settings by.'),
-      );
-
-      $form['save']['new'][] = array(
-          '#type' => 'submit',
-          '#value' => t('Save As New'),
-          '#validate' => array('user_import_template_has_name_validate', 'user_import_template_unique_name_validate', 'user_import_edit_validate'),
-          '#submit' => array('user_import_template_new_submit'),
-      );
+    $form['save'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Saved Settings'),
+      '#description' => t("If changes have neen made to the settings since they where last saved you can update the saved template, or save them as a new template."),
+      '#weight' => 90,
+      '#collapsible' => TRUE,
+      '#collapsed' => TRUE,
+    );
+
+    $form['#current_template'] = $import['name'];
+
+    $form['save']['update'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Update'),
+      '#description' => t("Update '%name' settings template", array('%name' => $import['name'])),
+    );
+
+    $form['save']['update']['submit'] = array(
+      '#type' => 'submit',
+      '#value' => t('Update'),
+      '#validate' => array('user_import_edit_validate'),
+      '#submit' => array('user_import_template_update_submit'),
+    );
+
+    $form['save']['new'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Create New'),
+      '#description' => t("Save as new settings template"),
+    );
+
+    $form['save']['new']['name'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Save As New'),
+      '#size' => 30,
+      '#maxlength' => 25,
+      '#description' => t('Name to identify these settings by.'),
+    );
+
+    $form['save']['new'][] = array(
+      '#type' => 'submit',
+      '#value' => t('Save As New'),
+      '#validate' => array('user_import_template_has_name_validate', 'user_import_template_unique_name_validate', 'user_import_edit_validate'),
+      '#submit' => array('user_import_template_new_submit'),
+    );
   }
 
   return;
@@ -300,24 +300,24 @@ function user_import_send_email_message_validate($element, &$form_state) {
 function _user_import_edit_remove_fields(&$form, $import) {
 
   $form['remove'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Use Different CSV File'),
-      '#description' => t('Remove file to use a different file. All settings on this page will be deleted.'),
-      '#weight' => -100,
-      '#collapsible' => TRUE,
-      '#collapsed' => TRUE,
+    '#type' => 'fieldset',
+    '#title' => t('Use Different CSV File'),
+    '#description' => t('Remove file to use a different file. All settings on this page will be deleted.'),
+    '#weight' => -100,
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
   );
 
   $form['remove']['file'] = array(
-      '#type' => 'item',
-      '#title' => t('Uploaded file: @filename', array('@filename' => $import['filename'])),
-      '#value' => $import['filename'],
+    '#type' => 'item',
+    '#title' => t('Uploaded file: @filename', array('@filename' => $import['filename'])),
+    '#value' => $import['filename'],
   );
 
   $form['remove']['submit'] = array(
-      '#type' => 'submit',
-      '#value' => t('Remove file'),
-      '#validate' => array('user_import_edit_remove_file_validate'),
+    '#type' => 'submit',
+    '#value' => t('Remove file'),
+    '#validate' => array('user_import_edit_remove_file_validate'),
   );
 
   return;
@@ -357,14 +357,14 @@ function _user_import_publication_email(&$variables, $account, $subscribed, $for
         if ($format == 1) {
 
           $variables['!subscribed_links'] .= '<strong>' . $publication->title . '</strong><br />' .
-          '<a href="' . $update_link . '">' . t('Update Preferences') . '</a> | <a href="' . $unsubscribe_link . '">' . t('Unsubscribe') . '</a><br />';
+            '<a href="' . $update_link . '">' . t('Update Preferences') . '</a> | <a href="' . $unsubscribe_link . '">' . t('Unsubscribe') . '</a><br />';
 
         }
         else {
 
           $variables['!subscribed_links'] .= $publication->title . "\n" .
-          ' - ' . t('Update Preferences') . ' ' . $update_link . '\n' .
-          ' - ' . t('Unsubscribe') . ' ' . $unsubscribe_link . '\n';
+            ' - ' . t('Update Preferences') . ' ' . $update_link . '\n' .
+            ' - ' . t('Unsubscribe') . ' ' . $unsubscribe_link . '\n';
         }
       }
     }
diff --git a/user_import.admin.inc b/user_import.admin.inc
index 3d96080..d9f2b47 100644
--- a/user_import.admin.inc
+++ b/user_import.admin.inc
@@ -7,52 +7,52 @@
 
 function user_import_list($action = NULL, $import_id = NULL) {
 
-	// clear incomplete imports
-	_user_import_incomplete_deletion();
+  // clear incomplete imports
+  _user_import_incomplete_deletion();
 
-	if (!empty($import_id) && is_numeric($import_id)) {
+  if (!empty($import_id) && is_numeric($import_id)) {
 
-	  $pager_id = 1;
-	  $limit = 10;
-	  $rows = array();
-	  $import = _user_import_settings_select($import_id);
-	
-	  $total = db_query('SELECT count(data) FROM {user_import_errors} WHERE import_id = :import_id', array(':import_id' => $import_id))->fetchField();
-	  //$results = pager_query("SELECT * FROM {user_import_errors} WHERE import_id = %d", $max, $pager_id, NULL, array($import['import_id']));
+    $pager_id = 1;
+    $limit = 10;
+    $rows = array();
+    $import = _user_import_settings_select($import_id);
+  
+    $total = db_query('SELECT count(data) FROM {user_import_errors} WHERE import_id = :import_id', array(':import_id' => $import_id))->fetchField();
+    //$results = pager_query("SELECT * FROM {user_import_errors} WHERE import_id = %d", $max, $pager_id, NULL, array($import['import_id']));
 
     // Select table
     $query = db_select('user_import_errors', 'imp_usr_errors');
 
     // Select fields
-		$query->fields('imp_usr_errors', array('import_id', 'data', 'errors' ));
-		
-		// Set conditions.
-		$query->condition('import_id', $import['import_id']);
-		
-		// For pagination
-		$query = $query->extend('TableSort')->extend('PagerDefault')->limit($limit);
-
-		// $result = $query
-		//  ->range(0, 1)
-		//  ->orderByHeader($header)
-		//  ->execute();
-		
-		// Execute query
-		$result = $query->execute();
+    $query->fields('imp_usr_errors', array('import_id', 'data', 'errors' ));
+    
+    // Set conditions.
+    $query->condition('import_id', $import['import_id']);
+    
+    // For pagination
+    $query = $query->extend('TableSort')->extend('PagerDefault')->limit($limit);
+
+    // $result = $query
+    //  ->range(0, 1)
+    //  ->orderByHeader($header)
+    //  ->execute();
+    
+    // Execute query
+    $result = $query->execute();
 
 
     foreach ($result as $line) {
-	    $rows[] = array('import_id' => $line->import_id, 'data' => unserialize($line->data), 'errors' => unserialize($line->errors));
-	  }
+      $rows[] = array('import_id' => $line->import_id, 'data' => unserialize($line->data), 'errors' => unserialize($line->errors));
+    }
 
     $output = theme('user_import_errors_display', array('import' => $import, 'file_lines' => $rows, 'total' => $total));  
 
-	} else {
+  } else {
 
-	  $output =  theme('user_import_list');
-	}
+    $output =  theme('user_import_list');
+  }
 
-	return $output;
+  return $output;
 }
 
 function user_import_preferences($import_id = NULL, $template_id = NULL) {
@@ -68,35 +68,35 @@ function user_import_preferences($import_id = NULL, $template_id = NULL) {
 
 function user_import_continue($import_id = NULL) {
 
-	if (!empty($import_id) && is_numeric($import_id)) {
+  if (!empty($import_id) && is_numeric($import_id)) {
     module_load_include('inc', 'user_import', 'user_import.import');
-		$import = _user_import_settings_select($import_id);
-		_user_import_process($import);
-	}
+    $import = _user_import_settings_select($import_id);
+    _user_import_process($import);
+  }
 
-	drupal_goto('admin/people/user_import');
+  drupal_goto('admin/people/user_import');
 }
 
 function user_import_import($import_id = NULL) {
 
-	if (!empty($import_id) && is_numeric($import_id)) {
+  if (!empty($import_id) && is_numeric($import_id)) {
 
-		$import = _user_import_settings_select($import_id);
-		_user_import_initialise_import($import);
-	}
+    $import = _user_import_settings_select($import_id);
+    _user_import_initialise_import($import);
+  }
 
-	drupal_goto('admin/people/user_import');
+  drupal_goto('admin/people/user_import');
 }
 
 function user_import_delete($import_id = NULL, $return_path = 'admin/people/user_import') {
 
-	if (empty($import_id) || !is_numeric($import_id)) drupal_goto($return_path);
+  if (empty($import_id) || !is_numeric($import_id)) drupal_goto($return_path);
 
-	$import = _user_import_settings_select($import_id);
-	_user_import_settings_deletion($import_id);
-	_user_import_file_deletion($import['filepath'], $import['filename'], $import['oldfilename'], $import['ftp']);
-	drupal_goto($return_path);
-	return;
+  $import = _user_import_settings_select($import_id);
+  _user_import_settings_deletion($import_id);
+  _user_import_file_deletion($import['filepath'], $import['filename'], $import['oldfilename'], $import['ftp']);
+  drupal_goto($return_path);
+  return;
 }
 
 /**
@@ -104,114 +104,114 @@ function user_import_delete($import_id = NULL, $return_path = 'admin/people/user
  */
 function user_import_configure_form() {
 
-    $form['performance'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Performance'),
-        '#collapsible' => TRUE,
-        '#collapsed' => TRUE,
-    );
+  $form['performance'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Performance'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+
+  $form['performance']['user_import_max'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Maximum Users/Process'),
+    '#default_value' => variable_get('user_import_max', 250),
+    '#size' => 10,
+    '#maxlength' => 10,
+    '#description' => t('Maximum number of users to import each time the file is processed, useful for controling the rate at which emails are sent out.'),
+  );
+
+  $form['performance']['user_import_line_max'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Maximum length of line'),
+    '#default_value' =>  variable_get('user_import_line_max', 1000),
+    '#size' => 10,
+    '#maxlength' => 10,
+    '#description' => t('The default is set at 1,000 characters, if a line in your csv is longer than this you should set a higher maximum here. Setting higher maximums will slow down imports.'),
+  );
 
-    $form['performance']['user_import_max'] = array(
-        '#type' => 'textfield',
-        '#title' => t('Maximum Users/Process'),
-        '#default_value' => variable_get('user_import_max', 250),
-        '#size' => 10,
-        '#maxlength' => 10,
-        '#description' => t('Maximum number of users to import each time the file is processed, useful for controling the rate at which emails are sent out.'),
+  if (module_exists('profile')) {
+    $date_options = array(
+      'MM/DD/YYYY' => 'MM/DD/YYYY',
+      'DD/MM/YYYY' => 'DD/MM/YYYY',
+      'YYYY/MM/DD' => 'YYYY/MM/DD',
+      'YYYY/DD/MM' => 'YYYY/DD/MM',
+    );
+    $form['profile'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Profile Settings'),
+      '#collapsible' => TRUE,
+      '#collapsed' => TRUE,
     );
+    $form['profile']['profile_date_format'] = array(
+      '#type' => 'select',
+      '#title' => t('Date field format'),
+      '#description' => t('Select a format for importing dates into user profiles (Profile module).'),
+      '#default_value' => variable_get('user_import_profile_date_format', 'MM/DD/YYYY'),
+      '#options' => $date_options,
+    );
+  }
+
+  $saved_templates = _user_import_settings_select(NULL, TRUE);
 
-    $form['performance']['user_import_line_max'] = array(
-        '#type' => 'textfield',
-        '#title' => t('Maximum length of line'),
-        '#default_value' =>  variable_get('user_import_line_max', 1000),
-        '#size' => 10,
-        '#maxlength' => 10,
-        '#description' => t('The default is set at 1,000 characters, if a line in your csv is longer than this you should set a higher maximum here. Setting higher maximums will slow down imports.'),
+  if (!empty($saved_templates)) {
+
+    $form['settings_templates'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Settings Templates'),
+      '#collapsible' => TRUE,
+      '#collapsed' => TRUE,
     );
 
-	  if (module_exists('profile')) {
-	    $date_options = array(
-	      'MM/DD/YYYY' => 'MM/DD/YYYY',
-	      'DD/MM/YYYY' => 'DD/MM/YYYY',
-	      'YYYY/MM/DD' => 'YYYY/MM/DD',
-	      'YYYY/DD/MM' => 'YYYY/DD/MM',
-	    );
-	    $form['profile'] = array(
-	      '#type' => 'fieldset',
-	      '#title' => t('Profile Settings'),
-	      '#collapsible' => TRUE,
-	      '#collapsed' => TRUE,
-	    );
-	    $form['profile']['profile_date_format'] = array(
-	      '#type' => 'select',
-	      '#title' => t('Date field format'),
-	      '#description' => t('Select a format for importing dates into user profiles (Profile module).'),
-	      '#default_value' => variable_get('user_import_profile_date_format', 'MM/DD/YYYY'),
-	      '#options' => $date_options,
-	    );
-	  }
-
-    $saved_templates = _user_import_settings_select(NULL, TRUE);
-
-    if (!empty($saved_templates)) {
-
-        $form['settings_templates'] = array(
-            '#type' => 'fieldset',
-            '#title' => t('Settings Templates'),
-            '#collapsible' => TRUE,
-            '#collapsed' => TRUE,
-        );
-
-        $templates_list = array('-- none --');
-
-        foreach ($saved_templates AS $template) {
-            $templates_list[$template['import_id']] = $template['name'];
-            $templates_delete[$template['import_id']] = $template['name'];
-        }
-
-        $form['settings_templates']['user_import_settings'] = array(
-            '#type' => 'select',
-            '#title' => t('Default Settings'),
-            '#description' => t('Select if you want to use a previously saved set of settings as default for all imports.'),
-            '#default_value' => variable_get('user_import_settings', 0),
-            '#options' => $templates_list,
-        );
-
-
-        $form['settings_templates']['templates'] = array(
-            '#type' => 'checkboxes',
-            '#title' => t('Delete Templates'),
-            '#options' => $templates_delete,
-        );
+    $templates_list = array('-- none --');
 
+    foreach ($saved_templates AS $template) {
+      $templates_list[$template['import_id']] = $template['name'];
+      $templates_delete[$template['import_id']] = $template['name'];
     }
 
-    $form['submit'] = array(
-        '#type' => 'submit',
-        '#value' => t('Save'),
-        );
+    $form['settings_templates']['user_import_settings'] = array(
+      '#type' => 'select',
+      '#title' => t('Default Settings'),
+      '#description' => t('Select if you want to use a previously saved set of settings as default for all imports.'),
+      '#default_value' => variable_get('user_import_settings', 0),
+      '#options' => $templates_list,
+    );
+
 
-    return $form;
+    $form['settings_templates']['templates'] = array(
+      '#type' => 'checkboxes',
+      '#title' => t('Delete Templates'),
+      '#options' => $templates_delete,
+    );
+
+  }
+
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Save'),
+  );
+
+  return $form;
 }
 
 function user_import_configure_form_validate($form, &$form_state) {
 
-    if (is_numeric($form_state['values']['user_import_max'])) {
-        if ($form_state['values']['user_import_max'] < 10) form_set_error('user_import_max', t("Value should be at least 10."));
-    }
-    else {
-        form_set_error('user_import_max', t('Value must be a number.'));
-    }
+  if (is_numeric($form_state['values']['user_import_max'])) {
+    if ($form_state['values']['user_import_max'] < 10) form_set_error('user_import_max', t("Value should be at least 10."));
+  }
+  else {
+    form_set_error('user_import_max', t('Value must be a number.'));
+  }
 
-    if (is_numeric($form_state['values']['user_import_line_max'])) {
-        if ($form_state['values']['user_import_line_max'] < 1000) form_set_error('user_import_line_max', t("Value must be higher than 1000."));
-        if ($form_state['values']['user_import_line_max'] > 1000000) form_set_error('user_import_line_max', t("Value must be lower than 1,000,000."));
-    }
-    else {
-        form_set_error('user_import_line_max', t('Value must be a number.'));
-    }
+  if (is_numeric($form_state['values']['user_import_line_max'])) {
+    if ($form_state['values']['user_import_line_max'] < 1000) form_set_error('user_import_line_max', t("Value must be higher than 1000."));
+    if ($form_state['values']['user_import_line_max'] > 1000000) form_set_error('user_import_line_max', t("Value must be lower than 1,000,000."));
+  }
+  else {
+    form_set_error('user_import_line_max', t('Value must be a number.'));
+  }
 
-    return;
+  return;
 }
 
 function user_import_configure_form_submit($form, &$form_state) {
@@ -222,20 +222,20 @@ function user_import_configure_form_submit($form, &$form_state) {
   variable_set('user_import_line_max', $form_state['values']['user_import_line_max']);
   variable_set('user_import_settings', $form_state['values']['user_import_settings']);
   $profile_date_format = isset($form_state['values']['profile_date_format']) ? $form_state['values']['profile_date_format'] : 0;
-	variable_set('user_import_profile_date_format', $profile_date_format);
+  variable_set('user_import_profile_date_format', $profile_date_format);
 
   if (!empty($form_state['values']['templates'])) {
 
-      foreach ($form_state['values']['templates'] as $import_id) {
+    foreach ($form_state['values']['templates'] as $import_id) {
 
-          if (!empty($import_id)) {
+      if (!empty($import_id)) {
 
-              $template = _user_import_settings_select($import_id);
-              if (!empty($deleted)) $deleted .= ', ';
-              $deleted .= $template['name'];
-              _user_import_settings_deletion($import_id);
-          }
+        $template = _user_import_settings_select($import_id);
+        if (!empty($deleted)) $deleted .= ', ';
+        $deleted .= $template['name'];
+        _user_import_settings_deletion($import_id);
       }
+    }
   }
 
   if (!empty($deleted)) drupal_set_message(t('Settings templates deleted: @deleted', array('@deleted' => $deleted)));
@@ -246,38 +246,38 @@ function user_import_configure_form_submit($form, &$form_state) {
 
 function user_import_add_form($import_id = NULL) {
 
-    $form = array();
-    $ftp_files = _user_import_ftp_files();
-    user_import_add_file_form($form, $ftp_files);
-    user_import_delimiter_form($form);
-    $settings = _user_import_settings_select(NULL, TRUE);
-
-    if ($settings) {
-
-        $saved_settings = array(t('-- none --'));
-        foreach ($settings AS $settings_set) {
-            $saved_settings[$settings_set['import_id']] = $settings_set['name'];
-        }
+  $form = array();
+  $ftp_files = _user_import_ftp_files();
+  user_import_add_file_form($form, $ftp_files);
+  user_import_delimiter_form($form);
+  $settings = _user_import_settings_select(NULL, TRUE);
 
-        $form['import_template_select'] = array(
-            '#type' => 'select',
-            '#title' => t('Saved Settings'),
-            '#description' => t('Select if you want to use a previously saved set of settings.'),
-            '#default_value' => variable_get('user_import_settings', 0),
-            '#options' => $saved_settings,
-        );
+  if ($settings) {
 
+    $saved_settings = array(t('-- none --'));
+    foreach ($settings AS $settings_set) {
+      $saved_settings[$settings_set['import_id']] = $settings_set['name'];
     }
 
-    $form['next'] = array(
-        '#type' => 'submit',
-        '#value' => t('Next')
+    $form['import_template_select'] = array(
+      '#type' => 'select',
+      '#title' => t('Saved Settings'),
+      '#description' => t('Select if you want to use a previously saved set of settings.'),
+      '#default_value' => variable_get('user_import_settings', 0),
+      '#options' => $saved_settings,
     );
 
-    // Set form parameters so we can accept file uploads.
-    $form['#attributes'] = array('enctype' => 'multipart/form-data');
+  }
+
+  $form['next'] = array(
+    '#type' => 'submit',
+    '#value' => t('Next')
+  );
+
+  // Set form parameters so we can accept file uploads.
+  $form['#attributes'] = array('enctype' => 'multipart/form-data');
 
-    return $form;
+  return $form;
 }
 
 function user_import_add_form_validate($form, &$form_state) {
@@ -309,28 +309,28 @@ function user_import_add_form_submit($form, &$form_state) {
   $redirect .= $import['import_id'];
 
   if (!empty($form_state['values']['import_template_select'])) {
-	  $redirect .= '/'. check_plain($form_state['values']['import_template_select']);
-	}
+    $redirect .= '/'. check_plain($form_state['values']['import_template_select']);
+  }
 
   $form_state['redirect'] = $redirect;
 }
 
 function user_import_delimiter_form(&$form, $value = ',') {
   $form['file_settings'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('File Settings'),
-      '#collapsible' => TRUE,
-			'#collapsed' => TRUE,
-      '#description' => t("File column delimiter"),
+    '#type' => 'fieldset',
+    '#title' => t('File Settings'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+    '#description' => t("File column delimiter"),
   );
 
   $form['file_settings']['delimiter'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Delimiter'),
-      '#size' => 4,
-      '#default_value' => $value,
-      '#required' => TRUE,
-      '#description' => t("The column delimiter for the file. Use '/t' for Tab."),
+    '#type' => 'textfield',
+    '#title' => t('Delimiter'),
+    '#size' => 4,
+    '#default_value' => $value,
+    '#required' => TRUE,
+    '#description' => t("The column delimiter for the file. Use '/t' for Tab."),
   );
 }
 
@@ -345,8 +345,8 @@ function user_import_edit($form, $form_state, $import_id, $template_id = NULL) {
   $import['template_id'] = $template_id;
 
   $form['ftp'] = array(
-      '#type' => 'value',
-      '#value' => $import['options']['ftp'],
+    '#type' => 'value',
+    '#value' => $import['options']['ftp'],
   );
 
   // add setting template values
@@ -355,23 +355,23 @@ function user_import_edit($form, $form_state, $import_id, $template_id = NULL) {
   }
 
   $form['import_id'] = array(
-      '#type' => 'value',
-      '#value' => $import_id,
+    '#type' => 'value',
+    '#value' => $import_id,
   );
 
   $form['setting'] = array(
-      '#type' => 'value',
-      '#value' => $import['setting'],
+    '#type' => 'value',
+    '#value' => $import['setting'],
   );
 
   $form['return_path'] = array(
-      '#type' => 'value',
-      '#default_value' => 'admin/people/user_import',
+    '#type' => 'value',
+    '#default_value' => 'admin/people/user_import',
   );
 
   $form['og_id'] = array(
-      '#type' => 'value',
-      '#default_value' => 0,
+    '#type' => 'value',
+    '#default_value' => 0,
   );
 
   // don't use hook because these need to be added in this order;
@@ -414,25 +414,25 @@ function user_import_edit($form, $form_state, $import_id, $template_id = NULL) {
   if ($import['setting'] != 'import' && $import['setting'] != 'imported') {
 
     $form['test'] = array(
-        '#type' => 'submit',
-        '#value' => t('Test'),
-        '#weight' => 100,
-        '#submit' => array('user_import_test_submit', 'user_import_edit_submit'),
+      '#type' => 'submit',
+      '#value' => t('Test'),
+      '#weight' => 100,
+      '#submit' => array('user_import_test_submit', 'user_import_edit_submit'),
     );
   }
 
   $form['import'] = array(
-      '#type' => 'submit',
-      '#value' => t('Import'),
-      '#weight' => 100,
-			'#submit' => array('user_import_import_submit', 'user_import_edit_submit'),
+    '#type' => 'submit',
+    '#value' => t('Import'),
+    '#weight' => 100,
+    '#submit' => array('user_import_import_submit', 'user_import_edit_submit'),
   );
 
   $form['cancel'] = array(
-      '#type' => 'submit',
-      '#value' => t('Cancel'),
-      '#weight' => 100,
-      '#validate' => array('user_import_edit_cancel_validate'),
+    '#type' => 'submit',
+    '#value' => t('Cancel'),
+    '#weight' => 100,
+    '#validate' => array('user_import_edit_cancel_validate'),
   );
 
   return $form;
@@ -442,9 +442,9 @@ function user_import_edit_cancel_validate($form, &$form_state) {
 
   // if import was being added - delete file
   if ($form_state['values']['setting'] == 'file set') {
-	  $settings = _user_import_settings_select($form_state['values']['import_id']);
-	  _user_import_settings_deletion($form_state['values']['import_id']);
-	  _user_import_file_deletion($settings['filepath'], $settings['filename'], $settings['oldfilename'], $settings['options']['ftp']);
+    $settings = _user_import_settings_select($form_state['values']['import_id']);
+    _user_import_settings_deletion($form_state['values']['import_id']);
+    _user_import_file_deletion($settings['filepath'], $settings['filename'], $settings['oldfilename'], $settings['options']['ftp']);
   }
 
   $form_state['redirect'] = 'admin/people/user_import';
@@ -470,11 +470,11 @@ function user_import_edit_validate($form, &$form_state) {
   if (!$email) form_set_error('email', t('One column of the csv file must be set as the email address.'));
 
   if ($form_state['values']['name']) {
-     $form_state['values']['name'] = rtrim($form_state['values']['name']);
+    $form_state['values']['name'] = rtrim($form_state['values']['name']);
 
-     if (drupal_strlen($form_state['values']['name']) < 1 || drupal_strlen($form_state['values']['name']) > 25) {
+    if (drupal_strlen($form_state['values']['name']) < 1 || drupal_strlen($form_state['values']['name']) > 25) {
       form_set_error('name', t('Name of saved settings must be 25 characters or less.'));
-     }
+    }
   }
 
   return;
@@ -536,8 +536,8 @@ function user_import_test_submit($form, &$form_state) {
  *
  */
 function user_import_import_submit($form, &$form_state) {
-	$form_state['values']['setting'] = 'import';
-	drupal_set_message (t('Imported'));
+  $form_state['values']['setting'] = 'import';
+  drupal_set_message (t('Imported'));
 }
 
 /**
@@ -547,21 +547,21 @@ function user_import_edit_submit($form, &$form_state) {
   // Deal with import being canceled.
   if ($form_state['clicked_button']['#value'] == t('Cancel')) {
     $form_state['redirect'] = 'admin/people/user_import';
-	  return;
+    return;
   }
 
   // Load import functions.
   module_load_include('inc', 'user_import', 'user_import.import');
 
-	if ($form_state['values']['setting'] == 'file set') {
+  if ($form_state['values']['setting'] == 'file set') {
     $file = new stdClass();
     $file->uri = $form_state['values']['filepath'];
     $file->filename = $form_state['values']['filename'];
-		$filepath = file_move($file, file_directory_path() .'/'. $form_state['values']['filename']);
-	}
+    $filepath = file_move($file, file_directory_path() .'/'. $form_state['values']['filename']);
+  }
 
-	if (!empty($form_state['values']['og_id'])) $form_state['values']['groups'][$form_state['values']['og_id']] = $form_state['values']['og_id'];
-	$form_state['values']['ftp'] = $form_state['values']['ftp'];
+  if (!empty($form_state['values']['og_id'])) $form_state['values']['groups'][$form_state['values']['og_id']] = $form_state['values']['og_id'];
+  $form_state['values']['ftp'] = $form_state['values']['ftp'];
   $form_state['values'] = _user_import_settings_save($form_state['values']);
   $form_state['values']['save']['update'] = NULL;
   $form_state['values']['import_template_id'] = NULL;
@@ -572,72 +572,72 @@ function user_import_edit_submit($form, &$form_state) {
 
 function user_import_add_file_form(&$form, $ftp_files = NULL) {
 
-    $form['browser'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Browser Upload'),
-        '#collapsible' => TRUE,
-        '#description' => t("Upload a CSV file."),
-    );
+  $form['browser'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Browser Upload'),
+    '#collapsible' => TRUE,
+    '#description' => t("Upload a CSV file."),
+  );
 
-		if (function_exists('file_upload_max_size')) {
-      $file_size = t('Maximum file size: %size.', array('%size' => format_size(file_upload_max_size())));
-    }
+  if (function_exists('file_upload_max_size')) {
+    $file_size = t('Maximum file size: %size.', array('%size' => format_size(file_upload_max_size())));
+  }
 
-    $form['browser']['file_upload'] = array(
-        '#type' => 'file',
-        '#title' => t('CSV File'),
-        '#size' => 40,
-        '#description' => t('Select the CSV file to be imported. ') . $file_size,
-    );
+  $form['browser']['file_upload'] = array(
+    '#type' => 'file',
+    '#title' => t('CSV File'),
+    '#size' => 40,
+    '#description' => t('Select the CSV file to be imported. ') . $file_size,
+  );
 
-    if (!empty($ftp_files)) {
+  if (!empty($ftp_files)) {
 
-      $form['ftp'] = array(
-          '#type' => 'fieldset',
-          '#title' => t('FTP Upload'),
-          '#collapsible' => TRUE,
-          '#collapsed' => TRUE,
-          '#description' => t("Any files uploaded to the 'user_import' directory using FTP can be selected for import here. Useful if the import file is too large for upload via the browser."),
-      );
+    $form['ftp'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('FTP Upload'),
+      '#collapsible' => TRUE,
+      '#collapsed' => TRUE,
+      '#description' => t("Any files uploaded to the 'user_import' directory using FTP can be selected for import here. Useful if the import file is too large for upload via the browser."),
+    );
 
-       $form['ftp']['file_ftp'] = array(
-            '#type' => 'radios',
-            '#title' => t('Files'),
-            '#default_value' => 0,
-            '#options' => $ftp_files,
-       );
-
-      // reload the page to show any files that have been added by FTP
-      $form['ftp']['scan'] = array(
-          '#type' => 'submit',
-          '#value' => t('Check for new files'),
-          '#validate' => array(),
-          '#submit' => array(),
-      );
+    $form['ftp']['file_ftp'] = array(
+      '#type' => 'radios',
+      '#title' => t('Files'),
+      '#default_value' => 0,
+      '#options' => $ftp_files,
+    );
 
-    }
+    // reload the page to show any files that have been added by FTP
+    $form['ftp']['scan'] = array(
+      '#type' => 'submit',
+      '#value' => t('Check for new files'),
+      '#validate' => array(),
+      '#submit' => array(),
+    );
 
-    return;
+  }
+
+  return;
 }
 
 function user_import_edit_file_fields(&$form, $import) {
 
-    $form['filename'] = array(
-        '#type' => 'value',
-        '#value' => $import['filename'],
-    );
+  $form['filename'] = array(
+    '#type' => 'value',
+    '#value' => $import['filename'],
+  );
 
-    $form['oldfilename'] = array(
-        '#type' => 'value',
-        '#value' => $import['oldfilename'],
-    );
+  $form['oldfilename'] = array(
+    '#type' => 'value',
+    '#value' => $import['oldfilename'],
+  );
 
-    $form['filepath'] = array(
-        '#type' => 'value',
-        '#value' => $import['filepath'],
-    );
+  $form['filepath'] = array(
+    '#type' => 'value',
+    '#value' => $import['filepath'],
+  );
 
-    return;
+  return;
 }
 
 // - - - - - - - -  FILE HANDLING - - - - - - - -
@@ -674,10 +674,10 @@ function _user_import_file_deletion($filepath, $filename, $old_filename, $ftp, $
   if (!$message) return;
 
   if (empty($removed)) {
-      drupal_set_message(t("File error: file '%old_filename' (%filename) could not be deleted.", array('%old_filename' => $oldfilename, '%filename' => $filename)), 'error');
+    drupal_set_message(t("File error: file '%old_filename' (%filename) could not be deleted.", array('%old_filename' => $oldfilename, '%filename' => $filename)), 'error');
   }
   else {
-      drupal_set_message(t("File '%old_filename' was deleted.", array('%old_filename' => $old_filename)));
+    drupal_set_message(t("File '%old_filename' was deleted.", array('%old_filename' => $old_filename)));
   }
 
   return;
@@ -691,36 +691,36 @@ function _user_import_file_deletion($filepath, $filename, $old_filename, $ftp, $
  */
 function _user_import_file($import_id = NULL, $ftp_file_selected = NULL) {
 
-    static $file;
-    if (!empty($file)) return $file;
-
-    // file was uploaded through browser
-    $file = file_save_upload('file_upload', array('file_validate_extensions' => array('csv txt')));
-    if (!empty($file) ) return $file;
-
-    // file was uploaded by FTP
-    if (!empty($ftp_file_selected)) {
-        $ftp_files = _user_import_ftp_files();
-        $filepath = drupal_get_path('module', 'user_import');
-        $filename = $ftp_files[$ftp_file_selected];
-        $file = new stdClass();
-        $file->uri = "$filepath/$filename";
-        $file->filepath = "$filepath/$filename";
-        $file->filename = $filename;
-        return $file;
-    }
+  static $file;
+  if (!empty($file)) return $file;
 
-   // use file info stored in database
-   if (!empty($import_id)) {
-        $import = _user_import_settings_select($import_id);
-        $file->uri = $import['filepath'];
-        $file->filepath = $import['filepath'];
-        $file->oldfilename = $import['oldfilename'];
-        $file->filename = $import['filename'];
-        return $file;
-   }
+  // file was uploaded through browser
+  $file = file_save_upload('file_upload', array('file_validate_extensions' => array('csv txt')));
+  if (!empty($file) ) return $file;
 
-    return;
+  // file was uploaded by FTP
+  if (!empty($ftp_file_selected)) {
+    $ftp_files = _user_import_ftp_files();
+    $filepath = drupal_get_path('module', 'user_import');
+    $filename = $ftp_files[$ftp_file_selected];
+    $file = new stdClass();
+    $file->uri = "$filepath/$filename";
+    $file->filepath = "$filepath/$filename";
+    $file->filename = $filename;
+    return $file;
+  }
+
+  // use file info stored in database
+  if (!empty($import_id)) {
+    $import = _user_import_settings_select($import_id);
+    $file->uri = $import['filepath'];
+    $file->filepath = $import['filepath'];
+    $file->oldfilename = $import['oldfilename'];
+    $file->filename = $import['filename'];
+    return $file;
+  }
+
+  return;
 }
 
 // get info on files  uploaded via FTP
@@ -728,14 +728,14 @@ function _user_import_ftp_files() {
 
   $directory = opendir( drupal_get_path('module', 'user_import') );
   $filenames[] = t('none');
-	$ignorable_files = array('.', '..', '.DS_Store', 'CVS', '.svn', '.git', 'user_import.test', 'API.txt', 'user_import.drush.inc',
-													 'README.txt', 'LICENSE.txt', 'UPDATES.txt', 'user_import.module', 'user_import.install', 'user_import.info',
-													 'user_import.admin.inc', 'user_import.import.inc', 'supported', 'tests');
+  $ignorable_files = array('.', '..', '.DS_Store', 'CVS', '.svn', '.git', 'user_import.test', 'API.txt', 'user_import.drush.inc',
+                     'README.txt', 'LICENSE.txt', 'UPDATES.txt', 'user_import.module', 'user_import.install', 'user_import.info',
+                     'user_import.admin.inc', 'user_import.import.inc', 'supported', 'tests');
 
   while ($file = readdir($directory)) {
     if (!in_array($file, $ignorable_files)) {
-	  	$filenames[] = $file;
-		}
+      $filenames[] = $file;
+    }
   }
 
   closedir($directory);
@@ -747,7 +747,7 @@ function  _user_import_incomplete_deletion() {
 
   $result = db_query("SELECT * FROM {user_import} WHERE setting = 'file set'");
 
-	foreach ($result as $import) {
+  foreach ($result as $import) {
     $options = unserialize($import->options);
     _user_import_file_deletion($import->filepath, $import->filename, $import->oldfilename, $options['ftp'], FALSE);
     _user_import_settings_deletion($import->import_id);
@@ -760,27 +760,27 @@ function  _user_import_incomplete_deletion() {
 
 function user_import_form_field_match(&$form, $import) {
 
-	$delimiter = isset($import['options']['delimiter']) && !empty($import['options']['delimiter']) ? $import['options']['delimiter'] : ',';
+  $delimiter = isset($import['options']['delimiter']) && !empty($import['options']['delimiter']) ? $import['options']['delimiter'] : ',';
   $collapsed = (empty($import['name'])) ? FALSE: TRUE;
   $handle = _user_import_file_open($form['filepath']['#value'], $form['filename']['#value']);
   $data_row = _user_import_file_row($form['filename']['#value'], $handle, $delimiter);
 
   $fieldmatch_description_parts = array(
-		'<strong>'. t('Drupal fields') .':</strong> '. t("Match columns in CSV file to drupal user fields, leave as '----' to ignore the column."),
-		'<strong>'. t('Username') .':</strong> '. t("If username is selected for multiple fields, the username will be built in the order selected. Otherwise, the username will be randomly generated."),
-		'<strong>'. t('Abbreviate') .':</strong> '. t("Use the first letter of a field in uppercase for the Username, e.g. 'john' -> 'J'."),
+    '<strong>'. t('Drupal fields') .':</strong> '. t("Match columns in CSV file to drupal user fields, leave as '----' to ignore the column."),
+    '<strong>'. t('Username') .':</strong> '. t("If username is selected for multiple fields, the username will be built in the order selected. Otherwise, the username will be randomly generated."),
+    '<strong>'. t('Abbreviate') .':</strong> '. t("Use the first letter of a field in uppercase for the Username, e.g. 'john' -> 'J'."),
   );
 
   $fieldmatch_description = theme('item_list', array('items' => $fieldmatch_description_parts));
 
   $form['field_match'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Field Match'),
-      '#description' => $fieldmatch_description,
-      '#weight' => -90,
-      '#collapsible' => TRUE,
-      '#collapsed' => $collapsed,
-      '#tree' => TRUE,
+    '#type' => 'fieldset',
+    '#title' => t('Field Match'),
+    '#description' => $fieldmatch_description,
+    '#weight' => -90,
+    '#collapsible' => TRUE,
+    '#collapsed' => $collapsed,
+    '#tree' => TRUE,
   );
 
   // add default and email address options
@@ -804,32 +804,32 @@ function user_import_form_field_match(&$form, $import) {
 
   foreach ($data_row as $data_cell) {
 
-      $form['field_match'][$row]= array(
-          '#tree' => TRUE,
-      );
+    $form['field_match'][$row]= array(
+      '#tree' => TRUE,
+    );
 
-      $form['field_match'][$row]['csv'] = array(
-          '#markup' => check_plain(drupal_substr($data_cell, 0, 40)),
-      );
+    $form['field_match'][$row]['csv'] = array(
+      '#markup' => check_plain(drupal_substr($data_cell, 0, 40)),
+    );
 
-      $form['field_match'][$row]['field_match'] = array(
-          '#type' => 'select',
-          '#default_value' => isset($import['field_match'][$row]['field_match']) ? $import['field_match'][$row]['field_match'] : $user_fields[0],
-          '#options' => $user_fields,
-      );
+    $form['field_match'][$row]['field_match'] = array(
+      '#type' => 'select',
+      '#default_value' => isset($import['field_match'][$row]['field_match']) ? $import['field_match'][$row]['field_match'] : $user_fields[0],
+      '#options' => $user_fields,
+    );
 
-      $form['field_match'][$row]['username'] = array(
-          '#type' => 'select',
-          '#default_value' => isset($import['field_match'][$row]['username']) ? $import['field_match'][$row]['username'] : $sort[0],
-          '#options' => $sort,
-      );
+    $form['field_match'][$row]['username'] = array(
+      '#type' => 'select',
+      '#default_value' => isset($import['field_match'][$row]['username']) ? $import['field_match'][$row]['username'] : $sort[0],
+      '#options' => $sort,
+    );
 
-      $form['field_match'][$row]['abbreviate'] = array(
-          '#type' => 'checkbox',
-          '#default_value' => isset($import['field_match'][$row]['abbreviate']) ? $import['field_match'][$row]['abbreviate'] : NULL,
-      );
+    $form['field_match'][$row]['abbreviate'] = array(
+      '#type' => 'checkbox',
+      '#default_value' => isset($import['field_match'][$row]['abbreviate']) ? $import['field_match'][$row]['abbreviate'] : NULL,
+    );
 
-      $row++;
+    $row++;
   }
 
   return;
@@ -838,73 +838,73 @@ function user_import_form_field_match(&$form, $import) {
 // get first row of file
 function _user_import_file_row($filename, $handle, $delimiter = ',') {
 
-	// Handle folks who may list 'tab' as 't' or 'tab'
-	if (strtolower($delimiter) == 't' || strtolower($delimiter) == 'tab') {
-		$delimiter = '\t';
-	}
+  // Handle folks who may list 'tab' as 't' or 'tab'
+  if (strtolower($delimiter) == 't' || strtolower($delimiter) == 'tab') {
+    $delimiter = '\t';
+  }
 
-	$data_row = @fgetcsv ($handle, 1000000, $delimiter);
+  $data_row = @fgetcsv ($handle, 1000000, $delimiter);
 
-	if (!$data_row) {
-	    form_set_error('file', t("Could not get data, the file '%filename' is either empty or has incompatible line endings.", array('%filename' => $filename)), 'error');
-	}
-	return $data_row;
+  if (!$data_row) {
+    form_set_error('file', t("Could not get data, the file '%filename' is either empty or has incompatible line endings.", array('%filename' => $filename)), 'error');
+  }
+  return $data_row;
 }
 
 // move from one stage to the next
 // set up all necessary variables
 function _user_import_initialise_import($import) {
 
-	//_user_import_process won't work w/o this include
-	module_load_include('inc', 'user_import', 'user_import.import');
-
-	switch ($import['setting']) {
-	  case 'imported':
-	      drupal_set_message(t('File has already been imported'), 'error');
-	      break;
-
-	  // add setting template values to new import settings
-	  case 'file set':
-	      if (empty($import['template_id'])) return $import;
-	      $template  = _user_import_settings_select($import['template_id']);
-	      $template['import_id'] = $import['import_id'];
-	      $template['filename'] = $import['filename'];
-	      $template['oldfilename'] = $import['oldfilename'];
-	      $template['filepath'] = $import['filepath'];
-	      $template['started'] = 0;
-	      $template['setting'] = 'file set';
-	      return $template;
-
-	  case 'test':
-	  case 'tested':
-	      $import['setting'] = 'import';
-	      $import['started'] = 0;
-	      $import['pointer'] = 0;
-	      $import['processed'] = 0;
-	      $import['valid'] = 0;
-	      _user_import_errors_display_delete($import['import_id']);
-	      _user_import_settings_save($import);
-	      _user_import_process($import);
-	      break;
-
-	  case 'template':
-	      unset($import['filename']);
-	      unset($import['oldfilename']);
-	      unset($import['filepath']);
-	      $import['started'] = 0;
-	      $import['pointer'] = 0;
-	      $import['processed'] = 0;
-	      $import['valid'] = 0;
-	      _user_import_settings_save($import);
-	      break;
-
-	  default:
-	      _user_import_process($import);
-	      drupal_set_message(t('Imported'));
-	      break;
-	}
-
-	return;
+  //_user_import_process won't work w/o this include
+  module_load_include('inc', 'user_import', 'user_import.import');
+
+  switch ($import['setting']) {
+    case 'imported':
+      drupal_set_message(t('File has already been imported'), 'error');
+      break;
+
+      // add setting template values to new import settings
+    case 'file set':
+      if (empty($import['template_id'])) return $import;
+      $template  = _user_import_settings_select($import['template_id']);
+      $template['import_id'] = $import['import_id'];
+      $template['filename'] = $import['filename'];
+      $template['oldfilename'] = $import['oldfilename'];
+      $template['filepath'] = $import['filepath'];
+      $template['started'] = 0;
+      $template['setting'] = 'file set';
+      return $template;
+
+    case 'test':
+    case 'tested':
+      $import['setting'] = 'import';
+      $import['started'] = 0;
+      $import['pointer'] = 0;
+      $import['processed'] = 0;
+      $import['valid'] = 0;
+      _user_import_errors_display_delete($import['import_id']);
+      _user_import_settings_save($import);
+      _user_import_process($import);
+      break;
+
+    case 'template':
+      unset($import['filename']);
+      unset($import['oldfilename']);
+      unset($import['filepath']);
+      $import['started'] = 0;
+      $import['pointer'] = 0;
+      $import['processed'] = 0;
+      $import['valid'] = 0;
+      _user_import_settings_save($import);
+      break;
+
+    default:
+      _user_import_process($import);
+      drupal_set_message(t('Imported'));
+      break;
+  }
+
+  return;
 }
 
 
@@ -914,44 +914,44 @@ function _user_import_initialise_import($import) {
  */
 function _user_import_errors_display_delete($import_id) {
   db_query('DELETE FROM {user_import_errors} WHERE import_id = :import_id', array(':import_id' => $import_id));
-	return;
+  return;
 }
 
 function _user_import_profile($key = 'fid', $return_value = NULL) {
 
-    if (!module_exists('profile')) return;
+  if (!module_exists('profile')) return;
 
-    static $fields_static;
-		$fields = array();
+  static $fields_static;
+  $fields = array();
 
-    // avoid making more than one database call for profile info
-    if (empty($fields_static)) {
+  // avoid making more than one database call for profile info
+  if (empty($fields_static)) {
 
-        $results = db_query("SELECT * FROM {profile_field}");
+    $results = db_query("SELECT * FROM {profile_field}");
 
-        while ($row = db_fetch_object($results)) {
-            // don't include private fields
-            if (user_access('administer users') || $row->visibility != PROFILE_PRIVATE) {
-                $fields_static[] = $row;
-            }
-        }
+    while ($row = db_fetch_object($results)) {
+      // don't include private fields
+      if (user_access('administer users') || $row->visibility != PROFILE_PRIVATE) {
+        $fields_static[] = $row;
+      }
     }
+  }
 
-    if (empty($fields_static)) return array();
+  if (empty($fields_static)) return array();
 
-    // return all profile fields info, or just specific type
-    if (empty($return_value)) {
+  // return all profile fields info, or just specific type
+  if (empty($return_value)) {
 
-        foreach ($fields_static as $field) {
-            $fields[$field->{$key}] = $field;
-        }
+    foreach ($fields_static as $field) {
+      $fields[$field->{$key}] = $field;
     }
-    else {
-        foreach ($fields_static as $field) {
-            $fields[$field->{$key}] = $field->{$return_value};
-        }
+  }
+  else {
+    foreach ($fields_static as $field) {
+      $fields[$field->{$key}] = $field->{$return_value};
     }
+  }
 
-    asort($fields);
-    return $fields;
+  asort($fields);
+  return $fields;
 }
diff --git a/user_import.import.inc b/user_import.import.inc
index 93004b9..d487fbe 100644
--- a/user_import.import.inc
+++ b/user_import.import.inc
@@ -4,133 +4,133 @@ function _user_import_process($settings) {
   // Load supported modules
   user_import_load_supported();
 
-	$remaining_data = FALSE;
-	$line_max = variable_get('user_import_line_max', 1000);
-	$import_max = variable_get('user_import_max', 250);
-	$field_match = _user_import_unconcatenate_field_match($settings['field_match']);
-	$update_setting = _user_import_update_user_check($settings['options']['update_user']);
-	$update_setting_per_module = $settings['options']['update_user'];
-	$username_data = array();
-	$username_order = array();
-	$username_abbreviate = array();
-	$first_line_skip = 0;
+  $remaining_data = FALSE;
+  $line_max = variable_get('user_import_line_max', 1000);
+  $import_max = variable_get('user_import_max', 250);
+  $field_match = _user_import_unconcatenate_field_match($settings['field_match']);
+  $update_setting = _user_import_update_user_check($settings['options']['update_user']);
+  $update_setting_per_module = $settings['options']['update_user'];
+  $username_data = array();
+  $username_order = array();
+  $username_abbreviate = array();
+  $first_line_skip = 0;
   $delimiter = isset($settings['delimiter']) && !empty($settings['delimiter']) ? $settings['delimiter'] : ',';
 
-	ini_set('auto_detect_line_endings', TRUE);
-	$handle = @fopen($settings['filepath'], "r");
+  ini_set('auto_detect_line_endings', TRUE);
+  $handle = @fopen($settings['filepath'], "r");
 
-	// move pointer to where test/import last finished
-	if ($settings['pointer'] != 0) fseek ($handle, $settings['pointer']);
+  // move pointer to where test/import last finished
+  if ($settings['pointer'] != 0) fseek ($handle, $settings['pointer']);
 
-	// start count of imports on this cron run
-	$processed_counter = 0;
+  // start count of imports on this cron run
+  $processed_counter = 0;
 
   while ($data = fgetcsv($handle, $line_max, $delimiter)) {
 
-		$errors = user_import_errors(FALSE, TRUE);
+    $errors = user_import_errors(FALSE, TRUE);
 
-		// if importing, check we are not over max number of imports per cron
-		if ($settings['setting'] == 'import' && $processed_counter >= $import_max) {
-	    $remaining_data = TRUE;
-	    break;
-		}
-
-		// don't process empty lines
-		$line_filled = (count($data) == 1 && drupal_strlen($data[0]) == 0) ? FALSE : TRUE;
-
-		if ($line_filled) {
-
-		    // check if this is first line - if so should we skip?
-		    if (!empty($settings['first_line_skip']) && $settings['processed'] == 0) {
-	        // reset to false on second process
-	        $first_line_skip = (empty($first_line_skip)) ? TRUE : FALSE;
-		    }
+    // if importing, check we are not over max number of imports per cron
+    if ($settings['setting'] == 'import' && $processed_counter >= $import_max) {
+      $remaining_data = TRUE;
+      break;
+    }
 
-		    if (!$first_line_skip) {
+    // don't process empty lines
+    $line_filled = (count($data) == 1 && drupal_strlen($data[0]) == 0) ? FALSE : TRUE;
 
-		        unset($errors, $fields);
-		        reset($field_match);
-		        $password = '';
+    if ($line_filled) {
 
-            // Process data cell.
-		        foreach ($field_match as $column_id => $column_settings) {
+      // check if this is first line - if so should we skip?
+      if (!empty($settings['first_line_skip']) && $settings['processed'] == 0) {
+        // reset to false on second process
+        $first_line_skip = (empty($first_line_skip)) ? TRUE : FALSE;
+      }
 
-		          $type = $column_settings['type'];
-		          $field_id = $column_settings['field_id'];
+      if (!$first_line_skip) {
 
-		          // Skip if this is a field used as part of a username but
-		          // not otherwise mapped for import.
-		          if ($type != 'username_part') {
-		            $fields[$type][$field_id] = module_invoke_all('user_import_data', $settings, $update_setting, $column_settings, $type, $field_id, $data, $column_id);
-		          }
-		          // Read in data if present for concatenating a user name.
-		          if ($column_settings['username'] > 0) {
+        unset($errors, $fields);
+        reset($field_match);
+        $password = '';
 
-		            $username_data[$column_id] = $data[$column_id];
-		            $username_order[$column_id] = $column_settings['username'];
-		            $username_abbreviate[$column_id]= $column_settings['abbreviate'];
-		          }
-		        }
+        // Process data cell.
+        foreach ($field_match as $column_id => $column_settings) {
 
-		        $errors = user_import_errors();
-		        $account = array();
-		        $existing_account = FALSE;
-		        $updated = FALSE;
+          $type = $column_settings['type'];
+          $field_id = $column_settings['field_id'];
 
-		        // if we update existing users matched by email (and therefore passed validation even if this email already exists)
-		        // look for and use an existing account.
-		        if ($update_setting && !empty($fields['user']['email'][0])) {
-		          $existing_account = user_load_by_mail($fields['user']['email'][0]);
-		          if ($existing_account) $account = (array) $existing_account;
-		        }
+          // Skip if this is a field used as part of a username but
+          // not otherwise mapped for import.
+          if ($type != 'username_part') {
+            $fields[$type][$field_id] = module_invoke_all('user_import_data', $settings, $update_setting, $column_settings, $type, $field_id, $data, $column_id);
+          }
+          // Read in data if present for concatenating a user name.
+          if ($column_settings['username'] > 0) {
 
-		        // if $account['uid'] is not empty then we can assume the account is being updated
-		        $account_additions = module_invoke_all('user_import_pre_save', $settings, $account, $fields, $errors, $update_setting_per_module);
+            $username_data[$column_id] = $data[$column_id];
+            $username_order[$column_id] = $column_settings['username'];
+            $username_abbreviate[$column_id]= $column_settings['abbreviate'];
+          }
+        }
 
-		        foreach($account_additions as $field_name => $value) {
-		          $account[$field_name] = $value;
-		        }
+        $errors = user_import_errors();
+        $account = array();
+        $existing_account = FALSE;
+        $updated = FALSE;
 
-		        if (empty($errors)) {
+        // if we update existing users matched by email (and therefore passed validation even if this email already exists)
+        // look for and use an existing account.
+        if ($update_setting && !empty($fields['user']['email'][0])) {
+          $existing_account = user_load_by_mail($fields['user']['email'][0]);
+          if ($existing_account) $account = (array) $existing_account;
+        }
 
-		           if ($settings['setting'] == 'import') {
+        // if $account['uid'] is not empty then we can assume the account is being updated
+        $account_additions = module_invoke_all('user_import_pre_save', $settings, $account, $fields, $errors, $update_setting_per_module);
 
-		             if ($existing_account) {
-		               $account = user_save($existing_account, $account);
-		               $updated = TRUE;
-		             }
-		             else {
-		               // Only set a user name if we are not updating an existing record.
-		               $account['name'] = _user_import_create_username($username_order, $username_data, $username_abbreviate, $settings['username_space']);
-		               $password = $account['pass'];
-		               $account = user_save('', $account);
-		             }
+        foreach($account_additions as $field_name => $value) {
+          $account[$field_name] = $value;
+        }
 
-		             module_invoke_all('user_import_after_save', $settings, $account, $password, $fields, $updated, $update_setting_per_module);
-		             $processed_counter++;
-		           }
-              $settings['processed']++;
-		          $settings['valid']++;
-		        }
+        if (empty($errors)) {
+
+          if ($settings['setting'] == 'import') {
+
+            if ($existing_account) {
+              $account = user_save($existing_account, $account);
+              $updated = TRUE;
+            }
+            else {
+              // Only set a user name if we are not updating an existing record.
+              $account['name'] = _user_import_create_username($username_order, $username_data, $username_abbreviate, $settings['username_space']);
+              $password = $account['pass'];
+              $account = user_save('', $account);
+            }
+
+            module_invoke_all('user_import_after_save', $settings, $account, $password, $fields, $updated, $update_setting_per_module);
+            $processed_counter++;
+          }
+          $settings['processed']++;
+          $settings['valid']++;
+        }
 
 
-		    }
+      }
 
-		    $settings['pointer'] = ftell($handle);
+      $settings['pointer'] = ftell($handle);
 
-		    // save lines that have fatal errors
-		    if (!empty($errors)) {
-		      $account_email = isset($account['email']) ? $account['email'] : '';
-		      _user_import_errors_display_save($settings['import_id'], $fields, $account_email, $errors);
-		    }
-		}
+      // save lines that have fatal errors
+      if (!empty($errors)) {
+        $account_email = isset($account['email']) ? $account['email'] : '';
+        _user_import_errors_display_save($settings['import_id'], $fields, $account_email, $errors);
+      }
+    }
 
-		$settings['setting'] = _user_import_save_progress($settings['setting'], $remaining_data, $settings['pointer'], $settings['processed'], $settings['valid'], $settings['import_id']);
+    $settings['setting'] = _user_import_save_progress($settings['setting'], $remaining_data, $settings['pointer'], $settings['processed'], $settings['valid'], $settings['import_id']);
 
   }
 
-	// Save progress.
-	$settings['setting'] = _user_import_save_progress($settings['setting'], $remaining_data, $settings['pointer'], $settings['processed'], $settings['valid'], $settings['import_id'], TRUE);
+  // Save progress.
+  $settings['setting'] = _user_import_save_progress($settings['setting'], $remaining_data, $settings['pointer'], $settings['processed'], $settings['valid'], $settings['import_id'], TRUE);
 
   fclose ($handle);
   return $settings;
@@ -149,37 +149,37 @@ function _user_import_create_username($order, $data, $abbreviate, $username_spac
 
   $username = '';
 
-	if (is_array($order)) {
+  if (is_array($order)) {
 
-	  asort($order);
-	  //reset($order);
+    asort($order);
+    //reset($order);
 
 
-	  //while (list ($file_column, $sequence) = each ($order)) {
+    //while (list ($file_column, $sequence) = each ($order)) {
     foreach ($order as $file_column => $sequence) {
 
-	    if (!empty($username) && !empty($username_space)) {
-	      $username .= ' ';
-	    }
+      if (!empty($username) && !empty($username_space)) {
+        $username .= ' ';
+      }
 
-	    if ($abbreviate[$file_column] == 1) {
-		    //$username .= trim(drupal_strtoupper(chr(ord($data[$file_column]))));
-		    $first_character = trim($data[$file_column]);
-		    $first_character = drupal_substr($first_character, 0, 1);
+      if ($abbreviate[$file_column] == 1) {
+        //$username .= trim(drupal_strtoupper(chr(ord($data[$file_column]))));
+        $first_character = trim($data[$file_column]);
+        $first_character = drupal_substr($first_character, 0, 1);
         $username .= drupal_strtoupper($first_character);
-	    }
-	    else {
-		    $username .= trim($data[$file_column]);
-	    }
+      }
+      else {
+        $username .= trim($data[$file_column]);
+      }
 
-	  }
-	}
+    }
+  }
 
-	if (empty($username)) $username = _user_import_random_username();
+  if (empty($username)) $username = _user_import_random_username();
 
-	$username = _user_import_sanitise_username($username);
-	$username = _user_import_unique_username($username, TRUE);
-	return $username;
+  $username = _user_import_sanitise_username($username);
+  $username = _user_import_unique_username($username, TRUE);
+  return $username;
 }
 
 /**
@@ -250,36 +250,36 @@ function _user_import_settings_update($pointer, $processed, $valid, $setting, $i
         'processed' => $processed,
         'valid' => $valid,
         'setting' => $setting
-        ))
+      ))
     ->condition('import_id', $import_id)
     ->execute();
 }
 
 function _user_import_random_username() {
-    $username = '';
-    $vowels = 'aoueiy';
-    $consonants = 'bcdfghjklmnpqrstvwxz';
-    $length = 8;
+  $username = '';
+  $vowels = 'aoueiy';
+  $consonants = 'bcdfghjklmnpqrstvwxz';
+  $length = 8;
 
-    mt_srand ((double) microtime() * 10000000);
-    $next_vowel = 0;
+  mt_srand ((double) microtime() * 10000000);
+  $next_vowel = 0;
 
-    for ($count = 0; $count <= $length; $count++) {
+  for ($count = 0; $count <= $length; $count++) {
 
-        if ($next_vowel) {
-            $rand = mt_rand(0, 5);
-            $username.= $vowels{$rand};
-            $next_vowel = 0;
+    if ($next_vowel) {
+      $rand = mt_rand(0, 5);
+      $username.= $vowels{$rand};
+      $next_vowel = 0;
 
-        }
-        else {
-            $rand = mt_rand(0, 19);
-            $username .= $consonants{$rand};
-            $next_vowel = 1;
-        }
     }
+    else {
+      $rand = mt_rand(0, 19);
+      $username .= $consonants{$rand};
+      $next_vowel = 1;
+    }
+  }
 
-    return $username;
+  return $username;
 }
 
 // check if any updates are to be made
@@ -294,17 +294,17 @@ function _user_import_update_user_check($settings) {
 
 function _user_import_errors_display_save($import_id, $data, $email, $errors) {
 
-	$data['email'] = $email;
+  $data['email'] = $email;
 
-	$id = db_insert('user_import_errors')
-	  ->fields(array(
-	      'import_id' => $import_id,
-	      'data' => serialize($data),
-	      'errors' => serialize($errors),
-	  ))
-	  ->execute();
+  $id = db_insert('user_import_errors')
+    ->fields(array(
+        'import_id' => $import_id,
+        'data' => serialize($data),
+        'errors' => serialize($errors),
+      ))
+    ->execute();
 
-	return;
+  return;
 }
 
 /**
@@ -313,8 +313,8 @@ function _user_import_errors_display_save($import_id, $data, $email, $errors) {
 function _user_import_save_progress($status, $remaining_data, $pointer, $processed, $valid, $import_id, $status_check = FALSE) {
 
   if ($status_check) {
-	  if ($status == 'import' && !$remaining_data) $status = 'imported';
-	  if ($status == 'test') $status = 'tested';
+    if ($status == 'import' && !$remaining_data) $status = 'imported';
+    if ($status == 'test') $status = 'tested';
   }
 
   _user_import_settings_update($pointer, $processed, $valid, $status, $import_id);
diff --git a/user_import.install b/user_import.install
index 0e9fefb..71db79d 100644
--- a/user_import.install
+++ b/user_import.install
@@ -6,13 +6,13 @@
  */
 
 /**
-* Implementation of hook_schema(). 
-*/
+ * Implementation of hook_schema(). 
+ */
 function user_import_schema() {
   $schema['user_import'] = array(
-     'description' => t("Settings for each import, and import setting templates."),
-     'fields' => array(
-        'import_id' => array(
+    'description' => t("Settings for each import, and import setting templates."),
+    'fields' => array(
+      'import_id' => array(
         'description' => t("ID key of import or template."),
         'type' => 'serial',
         'unsigned' => TRUE,
@@ -155,25 +155,25 @@ function user_import_update_3() {
   db_drop_primary_key($ret, 'user_import');
   db_change_field($ret, 'user_import', 'iid', 'import_id', array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), array('primary key' => array('import_id')));
   db_change_field($ret, 'user_import', 'first_line', 'first_line_skip', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'), array('primary key' => array('import_id')));
-	db_drop_index($ret, 'user_import_errors', 'import_id');
+  db_drop_index($ret, 'user_import_errors', 'import_id');
   db_change_field($ret, 'user_import_errors', 'iid', 'import_id', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'));
-	db_add_index($ret, 'user_import_errors', 'import_id', array('import_id'));
+  db_add_index($ret, 'user_import_errors', 'import_id', array('import_id'));
   return $ret;
 }
 
 function user_import_update_4() {
   $ret = array();
-	db_drop_index($ret, 'user_import_errors', 'import_id'); 
+  db_drop_index($ret, 'user_import_errors', 'import_id'); 
   db_change_field($ret, 'user_import_errors', 'error', 'errors', array('type' => 'text', 'size' => 'big', 'not null' => TRUE, 'serialize' => TRUE));
-	db_add_index($ret, 'user_import_errors', 'import_id', array('import_id'));
+  db_add_index($ret, 'user_import_errors', 'import_id', array('import_id'));
   return $ret;
 }
 
 function user_import_update_5() {
   $ret = array();
-	db_drop_index($ret, 'user_import_errors', 'import_id'); 
+  db_drop_index($ret, 'user_import_errors', 'import_id'); 
   db_change_field($ret, 'user_import_errors', 'errors', 'errors', array('type' => 'text', 'size' => 'big', 'not null' => TRUE, 'serialize' => TRUE));
-	db_add_index($ret, 'user_import_errors', 'import_id', array('import_id'));
+  db_add_index($ret, 'user_import_errors', 'import_id', array('import_id'));
   return $ret;
 }
 
@@ -192,20 +192,20 @@ function user_import_update_6002() {
 
   // Update each import.
   while ($import = db_fetch_array($result)) { 
-		$options = unserialize($import['options']);
-		$options['first_line_skip'] = $import['first_line_skip'];
-		$options['contact'] = $import['contact'];
-		$options['username_space'] = $import['username_space'];
-		$options['send_email'] = $import['send_email']; 
-		//Avoid using update_sql() as it has issues with serialized data.
+    $options = unserialize($import['options']);
+    $options['first_line_skip'] = $import['first_line_skip'];
+    $options['contact'] = $import['contact'];
+    $options['username_space'] = $import['username_space'];
+    $options['send_email'] = $import['send_email']; 
+    //Avoid using update_sql() as it has issues with serialized data.
     db_query("UPDATE {user_import} SET options = '%s' WHERE import_id = %d", serialize($options), $import['import_id']);
-	}
-	
-	$ret[] = update_sql('ALTER TABLE {user_import} DROP COLUMN first_line_skip');
-	$ret[] = update_sql('ALTER TABLE {user_import} DROP COLUMN contact');
-	$ret[] = update_sql('ALTER TABLE {user_import} DROP COLUMN username_space');
-	$ret[] = update_sql('ALTER TABLE {user_import} DROP COLUMN send_email');
-	
+  }
+  
+  $ret[] = update_sql('ALTER TABLE {user_import} DROP COLUMN first_line_skip');
+  $ret[] = update_sql('ALTER TABLE {user_import} DROP COLUMN contact');
+  $ret[] = update_sql('ALTER TABLE {user_import} DROP COLUMN username_space');
+  $ret[] = update_sql('ALTER TABLE {user_import} DROP COLUMN send_email');
+  
   return $ret;
 }
 
@@ -219,8 +219,8 @@ function user_import_update_6003() {
 }
 
 /**
-* Implementation of hook_uninstall().
-*/
+ * Implementation of hook_uninstall().
+ */
 function user_import_uninstall() {
   variable_del('user_import_settings');
   variable_del('user_import_max');
diff --git a/user_import.module b/user_import.module
index beeb374..186dae1 100644
--- a/user_import.module
+++ b/user_import.module
@@ -62,20 +62,20 @@ function user_import_permission() {
  */
 function user_import_menu() {
   $items['admin/people/user_import'] = array(
-      'title' => 'Import',
-      'description' => 'Import or update users from a comma separated file (csv).',
-      'page callback' => 'user_import_list',
-      'access arguments' => array('import users'),
-      'type' => MENU_LOCAL_TASK,
-      'file' => 'user_import.admin.inc',
-      );
+    'title' => 'Import',
+    'description' => 'Import or update users from a comma separated file (csv).',
+    'page callback' => 'user_import_list',
+    'access arguments' => array('import users'),
+    'type' => MENU_LOCAL_TASK,
+    'file' => 'user_import.admin.inc',
+  );
   $items['admin/people/user_import/list'] = array(
-      'title' => 'List Imports',
-      'access arguments' => array('import users'),
-      'weight' => -10,
-      'type' => MENU_DEFAULT_LOCAL_TASK,
-      'file' => 'user_import.admin.inc',
-      );
+    'title' => 'List Imports',
+    'access arguments' => array('import users'),
+    'weight' => -10,
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'file' => 'user_import.admin.inc',
+  );
   $items['admin/people/user_import/add'] = array(
     'title' => 'New Import',
     'page callback' => 'user_import_preferences',
@@ -236,35 +236,35 @@ function theme_user_import_list() {
 
   foreach ($imports as $import) {
 
-      // header labels
-      $import_label = ($import['setting'] == 'tested' || $import['setting'] == 'test') ? t('importable') : t('imported');
-      $header = array(t('file'), t('started'), t('processed'), $import_label, t('errors'), t('status'));
-
-      // info row
-      $errors = db_query('SELECT COUNT(import_id) FROM {user_import_errors} WHERE import_id = :import_id', array(':import_id' => $import['import_id']))->fetchField();
-      $errors_link = ($errors == 0) ? '0': l($errors, 'admin/people/user_import/errors/' . $import['import_id']);
-
-      $rows[0] = array(
-          check_plain($import['oldfilename']),
-          format_date($import['started'], 'small'),
-          array("data" => $import['processed'], "align" => 'center'),
-          array("data" => $import['valid'], "align" => 'center'),
-          array("data" => $errors_link, "align" => 'center'),
-          $import['setting'],
-      );
-
-      $output .= theme('table', array('header' => $header, 'rows' => $rows));
-
-      // action buttons
-      $settings_link = l(t('Settings'), 'admin/people/user_import/add/' . $import['import_id']);
-      $delete_link = l(t('Delete'), 'admin/people/user_import/delete/' . $import['import_id']);
-      $continue_link = l(t('Continue Processing'), 'admin/people/user_import/continue/' . $import['import_id']);
-      $import_link = l(t('Import'), 'admin/people/user_import/import/' . $import['import_id']);
-
-      $output .= $settings_link  . ' | ';
-      $output .= $delete_link;
-      if ($import['setting'] == 'tested' || $import['setting'] == 'test') $output .= ' | ' . $import_link;
-      if ($import['setting'] == 'test' || $import['setting']  == 'import') $output .= ' | ' . $continue_link;
+    // header labels
+    $import_label = ($import['setting'] == 'tested' || $import['setting'] == 'test') ? t('importable') : t('imported');
+    $header = array(t('file'), t('started'), t('processed'), $import_label, t('errors'), t('status'));
+
+    // info row
+    $errors = db_query('SELECT COUNT(import_id) FROM {user_import_errors} WHERE import_id = :import_id', array(':import_id' => $import['import_id']))->fetchField();
+    $errors_link = ($errors == 0) ? '0': l($errors, 'admin/people/user_import/errors/' . $import['import_id']);
+
+    $rows[0] = array(
+      check_plain($import['oldfilename']),
+      format_date($import['started'], 'small'),
+      array("data" => $import['processed'], "align" => 'center'),
+      array("data" => $import['valid'], "align" => 'center'),
+      array("data" => $errors_link, "align" => 'center'),
+      $import['setting'],
+    );
+
+    $output .= theme('table', array('header' => $header, 'rows' => $rows));
+
+    // action buttons
+    $settings_link = l(t('Settings'), 'admin/people/user_import/add/' . $import['import_id']);
+    $delete_link = l(t('Delete'), 'admin/people/user_import/delete/' . $import['import_id']);
+    $continue_link = l(t('Continue Processing'), 'admin/people/user_import/continue/' . $import['import_id']);
+    $import_link = l(t('Import'), 'admin/people/user_import/import/' . $import['import_id']);
+
+    $output .= $settings_link  . ' | ';
+    $output .= $delete_link;
+    if ($import['setting'] == 'tested' || $import['setting'] == 'test') $output .= ' | ' . $import_link;
+    if ($import['setting'] == 'test' || $import['setting']  == 'import') $output .= ' | ' . $continue_link;
   }
 
   return $output;
@@ -280,25 +280,25 @@ function theme_user_import_edit($variables) {
   foreach (element_children($form['field_match']) as $key) {
 
     $rows[] = array(
-        drupal_render($form['field_match'][$key]['csv']),
-        drupal_render($form['field_match'][$key]['field_match']),
-        drupal_render($form['field_match'][$key]['username']),
-        drupal_render($form['field_match'][$key]['abbreviate']),
+      drupal_render($form['field_match'][$key]['csv']),
+      drupal_render($form['field_match'][$key]['field_match']),
+      drupal_render($form['field_match'][$key]['username']),
+      drupal_render($form['field_match'][$key]['abbreviate']),
     );
   }
 
   $form['field_match']['#value'] = theme('table', array('header' => $header, 'rows' => $rows));
 
   if (isset($form['remove'])){
-      $output .= drupal_render($form['remove']);
+    $output .= drupal_render($form['remove']);
   }
 
   if (isset($form['options'])){
-      $output .= drupal_render($form['options']);
+    $output .= drupal_render($form['options']);
   }
 
   if (isset($form['field_match'])){
-      $output .= drupal_render($form['field_match']);
+    $output .= drupal_render($form['field_match']);
   }
 
   $output .= drupal_render_children($form);
@@ -307,81 +307,81 @@ function theme_user_import_edit($variables) {
 
 function theme_user_import_errors_display($settings) {
 
-	$output = '';
-	$header[0] = t('Email Address');
-	$data = $settings['file_lines'];
-	$total = $settings['total'];
-	$oldfilename = $settings['import']['oldfilename'];
-	$field_match = $settings['import']['field_match'];
-	$error_count = 0;
-	$field_match = _user_import_unconcatenate_field_match($field_match);
+  $output = '';
+  $header[0] = t('Email Address');
+  $data = $settings['file_lines'];
+  $total = $settings['total'];
+  $oldfilename = $settings['import']['oldfilename'];
+  $field_match = $settings['import']['field_match'];
+  $error_count = 0;
+  $field_match = _user_import_unconcatenate_field_match($field_match);
 
-	foreach ($data as $data_row) {
+  foreach ($data as $data_row) {
 
-	    $row = array();
+    $row = array();
 
-	    foreach ($data_row['data'] as $type => $fields) {
+    foreach ($data_row['data'] as $type => $fields) {
 
-	      if (!empty($fields)) {
+      if (!empty($fields)) {
 
-	        foreach ($fields as $field_id => $field_data) {
+        foreach ($fields as $field_id => $field_data) {
 
-	          foreach ($field_match as $column_info) {
+          foreach ($field_match as $column_info) {
 
-	            if ($column_info['type'] ==  $type && $column_info['field_id'] == $field_id) {
+            if ($column_info['type'] ==  $type && $column_info['field_id'] == $field_id) {
 
-	              if (!empty($column_info['username'])) {
-	                $header[$column_info['username']] = t('Name %sort', array('%sort' => $column_info['username']));
-	                $row[$column_info['username']] = array("data" => $field_data[0], "align" => "left");
-	              }
+              if (!empty($column_info['username'])) {
+                $header[$column_info['username']] = t('Name %sort', array('%sort' => $column_info['username']));
+                $row[$column_info['username']] = array("data" => $field_data[0], "align" => "left");
+              }
 
-	              if ($column_info['field_id'] == 'email') {
-	                $row[0] = array("data" => $field_data[0], "align" => "left");
-	              }
-	            }
-	          }
+              if ($column_info['field_id'] == 'email') {
+                $row[0] = array("data" => $field_data[0], "align" => "left");
+              }
+            }
+          }
 
-	        }
-	      }
-	    }
+        }
+      }
+    }
 
-	    ksort($row);
-	    $row[] = implode('<br />', $data_row['errors']);
-	    $rows[] = $row;
-	}
+    ksort($row);
+    $row[] = implode('<br />', $data_row['errors']);
+    $rows[] = $row;
+  }
 
-	$output .= '<p>' . t('<strong>CSV File:</strong> %file', array('%file' => $oldfilename)) . '<br />';
-	$output .= t('<strong>Errors:</strong> !total', array('!total' => $total)) . '</p>';
+  $output .= '<p>' . t('<strong>CSV File:</strong> %file', array('%file' => $oldfilename)) . '<br />';
+  $output .= t('<strong>Errors:</strong> !total', array('!total' => $total)) . '</p>';
 
-	$header['errors'] = t('Errors');
-	
+  $header['errors'] = t('Errors');
+  
   // Output of table with the paging
   $output .= theme('table',
-    array(
-      "header" => $header,
-      "rows" => $rows,
-      "attributes" => array(),
-      "sticky" => FALSE, // Table header will be sticky
-      "caption" => '',
-      "colgroups" => array(),
-      "empty" => t("There are no errors.") // The message to be displayed if table is empty
-    )
-  ).theme("pager");
-	
-	//$output .= theme('table', array('header' => $header, 'rows' => $rows));
-	return $output;
+             array(
+               "header" => $header,
+               "rows" => $rows,
+               "attributes" => array(),
+               "sticky" => FALSE, // Table header will be sticky
+               "caption" => '',
+               "colgroups" => array(),
+               "empty" => t("There are no errors.") // The message to be displayed if table is empty
+             )
+                  ).theme("pager");
+  
+  //$output .= theme('table', array('header' => $header, 'rows' => $rows));
+  return $output;
 }
 
 function theme_user_import_username_errors($errors) {
 
-    if (empty($errors)) {
-        $output = '<p><strong>' . t('All usernames are OK.') . '</strong></p>';
-    } else {
-        $header = array(t('User ID'), t('Email'), t('Username'), t('Error'));
-        $output = theme('table', array('header' => $header, 'errors' => $errors));
-    }
+  if (empty($errors)) {
+    $output = '<p><strong>' . t('All usernames are OK.') . '</strong></p>';
+  } else {
+    $header = array(t('User ID'), t('Email'), t('Username'), t('Error'));
+    $output = theme('table', array('header' => $header, 'errors' => $errors));
+  }
 
-    return $output;
+  return $output;
 }
 
 // - - - - - - - -  MISC - - - - - - - -
@@ -389,18 +389,18 @@ function theme_user_import_username_errors($errors) {
 function _user_import_settings_save($settings) {
   // Database field defaults.
   $database_fields = array('import_id' => NULL,
-                           'name' => '',
-                           'filename' => '',
-                           'oldfilename' => '',
-                           'filepath' => '',
-                           'started' => 0,
-                           'pointer' => 0,
-                           'processed' => 0,
-                           'valid' => 0,
-                           'field_match' => array(),
-                           'roles' => '',
-                           'options' => array(),
-                           'setting' => '',
+                     'name' => '',
+                     'filename' => '',
+                     'oldfilename' => '',
+                     'filepath' => '',
+                     'started' => 0,
+                     'pointer' => 0,
+                     'processed' => 0,
+                     'valid' => 0,
+                     'field_match' => array(),
+                     'roles' => '',
+                     'options' => array(),
+                     'setting' => '',
                           );
 
   // Form elements we never want to save in the options column.
@@ -437,7 +437,7 @@ function _user_import_settings_save($settings) {
           'roles' => (isset($settings['roles'])) ? serialize($settings['roles']) : '',
           'options' => (isset($settings['options'])) ? serialize($settings['options']) : '',
           'setting' =>  (isset($settings['setting'])) ? $settings['setting'] : ''
-          ))
+        ))
       ->condition('import_id', $settings['import_id'])
       ->execute();
 
@@ -459,7 +459,7 @@ function _user_import_settings_save($settings) {
           'options' => (isset($settings['options'])) ? serialize($settings['options']) : '',
           'setting' =>  (isset($settings['setting'])) ? $settings['setting'] : '',
 
-      ))
+        ))
       ->execute();
   }
 
@@ -499,16 +499,16 @@ function _user_import_settings_select($import_id = NULL, $template = FALSE) {
     $result = db_query($query);
 
     foreach ($result as $row_data) {
-        $row = (array) $row_data;
-        $row['field_match'] = unserialize($row['field_match']);
-        $row['roles'] = unserialize($row['roles']);
-        $row['options'] = unserialize($row['options']);
+      $row = (array) $row_data;
+      $row['field_match'] = unserialize($row['field_match']);
+      $row['roles'] = unserialize($row['roles']);
+      $row['options'] = unserialize($row['options']);
 
-    foreach ($row['options'] as $key => $value) {
-      $row[$key] = $value;
-    }
+      foreach ($row['options'] as $key => $value) {
+        $row[$key] = $value;
+      }
 
-        $import[] = $row;
+      $import[] = $row;
     }
   }
 
@@ -516,15 +516,15 @@ function _user_import_settings_select($import_id = NULL, $template = FALSE) {
 }
 
 function _user_import_settings_deletion($import_id) {
-    db_delete('user_import')
-      ->condition('import_id', $import_id)
-      ->execute();
+  db_delete('user_import')
+    ->condition('import_id', $import_id)
+    ->execute();
 
-    db_delete('user_import_errors')
-      ->condition('import_id', $import_id)
-      ->execute();
+  db_delete('user_import_errors')
+    ->condition('import_id', $import_id)
+    ->execute();
 
-    return;
+  return;
 }
 
 // Used by user_import_og.module
@@ -591,8 +591,8 @@ function user_import_load_supported() {
 }
 
 /**
-* Implementation of hook_simpletest().
-*/
+ * Implementation of hook_simpletest().
+ */
 function user_import_simpletest() {
   $module_name = 'user_import';
   $dir = drupal_get_path('module', $module_name). '/tests';
