diff --git a/plugins/FeedsCSVParser.inc b/plugins/FeedsCSVParser.inc
index 337dd68..6b19c2a 100644
--- a/plugins/FeedsCSVParser.inc
+++ b/plugins/FeedsCSVParser.inc
@@ -116,40 +116,43 @@ class FeedsCSVParser extends FeedsParser {
    * Show mapping configuration as a guidance for import form users.
    */
   public function sourceForm($source_config) {
+
+    // This function is called several times without $source_config on the import-page, 
+    // which is not properly set in FeedsSource::configForm().
+    // Therefor, the CSV-settings (delimiter, no_header) on the form are incorrect.
+    // TODO: We better never use the parameter.
+    $source_config = $this->config;
+    $delimiter = isset($this->config['delimiter']) ? $this->config['delimiter'] : ',';
+
     $form = array();
+    $form_state = array();
     $form['#weight'] = -10;
 
+    // Collect columns, putting unique cids in front.
     $mappings = feeds_importer($this->id)->processor->config['mappings'];
     $sources = $uniques = array();
     foreach ($mappings as $mapping) {
-      $sources[] = check_plain($mapping['source']);
+      $source = check_plain(trim($mapping['source']));
       if ($mapping['unique']) {
-        $uniques[] = check_plain($mapping['source']);
+        $uniques[] = $source;
+      }
+      elseif (!in_array($source, $sources)) {
+        $sources[] = $source;
       }
     }
+    $sources = array_merge($uniques, $sources);
 
     $output = t('Import !csv_files with one or more of these columns: !columns.', array('!csv_files' => l(t('CSV files'), 'http://en.wikipedia.org/wiki/Comma-separated_values'), '!columns' => implode(', ', $sources)));
     $items = array();
     $items[] = format_plural(count($uniques), t('Column <strong>!column</strong> is mandatory and considered unique: only one item per !column value will be created.', array('!column' => implode(', ', $uniques))), t('Columns <strong>!columns</strong> are mandatory and values in these columns are considered unique: only one entry per value in one of these column will be created.', array('!columns' => implode(', ', $uniques))));
     $items[] = l(t('Download a template'), 'import/' . $this->id . '/template');
     $form['help']['#markup'] = '<div class="help"><p>' . $output . '</p>' . theme('item_list', array('items' => $items)) . '</div>';
-    $form['delimiter'] = array(
-      '#type' => 'select',
-      '#title' => t('Delimiter'),
-      '#description' => t('The character that delimits fields in the CSV file.'),
-      '#options'  => array(
-        ',' => ',',
-        ';' => ';',
-        'TAB' => 'TAB',
-      ),
-      '#default_value' => isset($source_config['delimiter']) ? $source_config['delimiter'] : ',',
-    );
-    $form['no_headers'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('No Headers'),
-      '#description' => t('Check if the imported CSV file does not start with a header row. If checked, mapping sources must be named \'0\', \'1\', \'2\' etc.'),
-      '#default_value' => isset($source_config['no_headers']) ? $source_config['no_headers'] : 0,
-    );
+
+    // reuse the configForm in this part of the form, overriding some texts.
+    $form = array_merge($form, $this->configForm($form_state));
+    $form['delimiter']['#title'] = t('Delimiter');
+    $form['delimiter']['#description'] = t('The character that delimits fields in the CSV file.');
+
     return $form;
   }
 
@@ -185,28 +188,35 @@ class FeedsCSVParser extends FeedsParser {
       '#description' => t('Check if the imported CSV file does not start with a header row. If checked, mapping sources must be named \'0\', \'1\', \'2\' etc.'),
       '#default_value' => $this->config['no_headers'],
     );
+
     return $form;
   }
 
   public function getTemplate() {
+
+    // Collect columns, putting unique cids in front.
     $mappings = feeds_importer($this->id)->processor->config['mappings'];
     $sources = $uniques = array();
     foreach ($mappings as $mapping) {
+      $source = check_plain(trim($mapping['source']));
       if ($mapping['unique']) {
-        $uniques[] = check_plain($mapping['source']);
+        $uniques[] = $source;
       }
-      else {
-        $sources[] = check_plain($mapping['source']);
+      elseif (!in_array($source, $sources)) {
+        $sources[] = $source;
       }
     }
-    $sep = ',';
+    $sources = array_merge($uniques, $sources);
+
+    $delimiter = isset($this->config['delimiter']) ? $this->config['delimiter'] : ',';
     $columns = array();
-    foreach (array_merge($uniques, $sources) as $col) {
-      if (strpos($col, $sep) !== FALSE) {
+    foreach ($sources as $col) {
+      if (strpos($col, $delimiter) !== FALSE) {
         $col = '"' . str_replace('"', '""', $col) . '"';
       }
       $columns[] = $col;
     }
+
     drupal_add_http_header('Cache-Control', 'max-age=60, must-revalidate');
     drupal_add_http_header('Content-Disposition', 'attachment; filename="' . $this->id . '_template.csv"');
     drupal_add_http_header('Content-type', 'text/csv; charset=utf-8');
