diff --git a/path_redirect_import.module b/path_redirect_import.module
index 2e16de1..bd701a4 100755
--- a/path_redirect_import.module
+++ b/path_redirect_import.module
@@ -1,7 +1,12 @@
 <?php
 
 /**
- * Implementation of hook_menu().
+ * @file
+ * Page and form to import drupal path redirects
+ */
+
+/**
+ * Implements of hook_menu().
  */
 function path_redirect_import_menu() {
   $items['admin/config/search/redirect/import'] = array(
@@ -15,7 +20,7 @@ function path_redirect_import_menu() {
   return $items;
 }
 
-/*
+/**
  *  form for import redirect path
  */
 function path_redirect_import_form() {
@@ -23,9 +28,26 @@ function path_redirect_import_form() {
   $form['csv'] = array(
     '#type' => 'fieldset',
     '#title' => t('Import from .csv file'),
-    '#description' => t('To import redirects, you must create a CSV file in the same format as <a href="@sample_url">this sample file</a>.',
-                        array('@sample_url' => base_path() . drupal_get_path('module', 'path_redirect_import') . '/redirect-import-sample.csv'))
+    '#description' => t('To import redirects, you must create a CSV or TXT.'),
+  );
+
+  $form['csv']['delimiter'] = array(
+    '#type' => 'select',
+    '#title' => t('Default delimiter'),
+    '#description' => t('Default field delimiter.'),
+    '#options' => array(
+      ',' => ',',
+      ';' => ';',
+      '#' => '#',
+      '|' => '|',
+    ),
+  );
+  $form['csv']['no_headers'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('No headers'),
+    '#description' => t('Check if the imported file does not start with a header row.'),
   );
+
   $form['csv']['csv_file'] = array(
     '#type' => 'file',
     '#description' => t('The CSV file must include columns in the following order: "From URL","To URL","Redirect Code" (defaults to 301)'),
@@ -34,11 +56,12 @@ function path_redirect_import_form() {
   $form['#attributes'] = array('enctype' => "multipart/form-data");
   return $form;
 }
-/*
+
+/**
  * validate form function
  */
 function path_redirect_import_form_validate($form, &$form_state) {
-  $validators = array('file_validate_extensions' => array('csv'));
+  $validators = array('file_validate_extensions' => array('csv txt'));
   if ($file = file_save_upload('csv_file', $validators)) {
     $form_state['uploaded_file'] = $file;
   }
@@ -46,7 +69,8 @@ function path_redirect_import_form_validate($form, &$form_state) {
     form_set_error('form', t('File upload failed.'));
   }
 }
-/*
+
+/**
  * Submit form function
  */
 function path_redirect_import_form_submit($form, &$form_state) {
@@ -59,11 +83,14 @@ function path_redirect_import_form_submit($form, &$form_state) {
   }
   $line_no = 0;
   $count = 0;
-  while ($line = fgetcsv($f, 1024, ",")) {
+
+  $delimiter = $form_state['values']['delimiter'];
+  while ($line = fgetcsv($f, 1024, $delimiter)) {
     $line_no++;
-    if ($line_no == 1) {
+    if ($line_no == 1 && !$form_state['values']['no_headers']) {
       continue;
     }
+
     $error = '';
     if (!is_array($line)) {
       $error .= t('Line %line_no is invalid.', array('%line_no' => $line_no)) . '<br />';
@@ -74,21 +101,23 @@ function path_redirect_import_form_submit($form, &$form_state) {
     if (empty($line[2])) {
       $line[2] = '301';
     }
+
+    $source_parts = redirect_parse_url($line[0]);
     $data = array(
-      'source' => $line[0],
-      'redirect' => $line[1],
+      'source' => $source_parts['url'],
+      'redirect' => isset($line[1]) ? $line[1] : NULL,
       'state_code' => $line[2],
     );
     if ($error == '') {
       if (!path_redirect_import_save_data($data)) {
         drupal_set_message(t('Inserting the data in the database has failed.'), 'error');
       }
-      else{
+      else {
         $count++;
       }
     }
     else {
-      drupal_set_message($error, 'error');
+      drupal_set_message(filter_xss($error), 'error');
     }
   }
   fclose($f);
@@ -98,11 +127,11 @@ function path_redirect_import_form_submit($form, &$form_state) {
   }
 }
 
-/*
+/**
  * Function for save data from .csv file into the database
  */
 function path_redirect_import_save_data($data) {
-  $redirect = (object)$data;
+  $redirect = (object) $data;
   $redirect->override = 0;
   $redirect_path = $redirect->redirect;
   if ($redirect->redirect != '<front>') {
@@ -116,8 +145,9 @@ function path_redirect_import_save_data($data) {
     if (!empty($parts['scheme']) && $parts['scheme'] == 'https') {
       $redirect->redirect_options['https'] = TRUE;
     }
+
     if (!url_is_external($parts['url'])) {
-      if (drupal_lookup_path('source', $parts['url'], LANGUAGE_NONE)) {
+      if (drupal_valid_path($parts['url'])) {
         $redirect->redirect = drupal_get_normal_path($parts['url'], LANGUAGE_NONE);
       }
       else {
@@ -128,6 +158,7 @@ function path_redirect_import_save_data($data) {
       $redirect->redirect = $parts['url'];
     }
   }
+
   redirect_object_prepare($redirect);
   redirect_hash($redirect);
   if ($existing = redirect_load_by_hash($redirect->hash)) {
