diff --git a/bin/gscan2pdf b/bin/gscan2pdf
index 362abf1..209cd1b 100755
--- a/bin/gscan2pdf
+++ b/bin/gscan2pdf
@@ -5307,8 +5307,8 @@ sub update_number {
 
 sub scanimage {
  my (
-  $device,   $npages,  $offset, $step, $rfacing,
-  $rreverse, $unpaper, $ocr,    %options
+  $device,   $npages,       $offset, $step, $rfacing,
+  $rreverse, $unpaper_flag, $ocr,    %options
  ) = @_;
 
  require IPC::Open3;
@@ -5405,7 +5405,7 @@ sub scanimage {
         sub {
          return TRUE unless ( -e "out$id.pnm" );
          my $index = import_scan( "out$id.pnm", $id * $step + $offset,
-          $SETTING{resolution}, TRUE, $rotate, $unpaper, $ocr );
+          $SETTING{resolution}, TRUE, $rotate, $unpaper_flag, $ocr );
          $num_scans++;
          return FALSE;
         }
@@ -5487,7 +5487,7 @@ sub scanimage {
  else {
   my $rotate = 1 % 2 ? $rfacing : $rreverse;
   my $index = import_scan( $test_image, 1 * $step + $offset,
-   $SETTING{resolution}, FALSE, $rotate, $unpaper, $ocr );
+   $SETTING{resolution}, FALSE, $rotate, $unpaper_flag, $ocr );
  }
  return;
 }
@@ -5496,8 +5496,8 @@ sub scanimage {
 
 sub scanadf {
  my (
-  $device,   $npages,  $offset, $step, $rfacing,
-  $rreverse, $unpaper, $ocr,    %options
+  $device,   $npages,       $offset, $step, $rfacing,
+  $rreverse, $unpaper_flag, $ocr,    %options
  ) = @_;
 
  require IPC::Open3;
@@ -5617,7 +5617,7 @@ sub scanadf {
         sub {
          return TRUE unless ( -e "out$id.pnm" );
          my $index = import_scan( "out$id.pnm", $id * $step + $offset,
-          $SETTING{resolution}, TRUE, $rotate, $unpaper, $ocr );
+          $SETTING{resolution}, TRUE, $rotate, $unpaper_flag, $ocr );
          $spbar->set_text(
           sprintf( $d->get('Scanning page %i...'), $id * $step + $offset ) );
          $id++;
@@ -5696,7 +5696,7 @@ sub update_spbar {
 }
 
 sub scan_pages {
- my ( $npages, $start, $step, $rfacing, $rreverse, $unpaper, $ocr ) = @_;
+ my ( $npages, $start, $step, $rfacing, $rreverse, $unpaper_flag, $ocr ) = @_;
  my $i      = 1;
  my $format = "out%d.pnm";
 
@@ -5734,7 +5734,7 @@ sub scan_pages {
    # show an error
    my $rotate = $n % 2 ? $rfacing : $rreverse;
    if ( defined $test_image ) {
-    import_scan( $test_image, $n, undef, FALSE, $rotate, $unpaper, $ocr );
+    import_scan( $test_image, $n, undef, FALSE, $rotate, $unpaper_flag, $ocr );
    }
    else {
     $SETTING{resolution} =
@@ -5743,7 +5743,7 @@ sub scan_pages {
       : $Gscan2pdf::Document::POINTS_PER_INCH;
     $logger->info("Importing scan with resolution=$SETTING{resolution}");
     import_scan( File::Spec->catdir( $session, "out$n.pnm" ),
-     $n, $SETTING{resolution}, TRUE, $rotate, $unpaper, $ocr );
+     $n, $SETTING{resolution}, TRUE, $rotate, $unpaper_flag, $ocr );
    }
 
    update_spbar( $i, $npages );
@@ -5783,18 +5783,18 @@ sub hash2options {
 }
 
 sub post_process_scan {
- my ( $pages, $rotate, $unpaper, $ocr ) = @_;
+ my ( $pages, $rotate, $unpaper_flag, $ocr ) = @_;
 
  if ($rotate) {
   rotate(
    $rotate, $pages,
    sub {
     my ($pages) = @_;
-    post_process_scan( $pages, undef, $unpaper, $ocr );
+    post_process_scan( $pages, undef, $unpaper_flag, $ocr );
    }
   );
  }
- elsif ($unpaper) {
+ elsif ($unpaper_flag) {
   unpaper_page(
    $pages,
    $unpaper->get_cmdline,
@@ -5813,7 +5813,8 @@ sub post_process_scan {
 # Take new scan and display it
 
 sub import_scan {
- my ( $ofilename, $page, $resolution, $delete, $rotate, $unpaper, $ocr ) = @_;
+ my ( $ofilename, $page, $resolution, $delete, $rotate, $unpaper_flag, $ocr ) =
+   @_;
 
  # Interface to frontend
  open my $fh, '<', $ofilename or die "can't open $ofilename: $!";   ## no critic
@@ -5882,7 +5883,7 @@ sub import_scan {
     }
     else {
      update_uimanager();
-     post_process_scan( [$gpage], $rotate, $unpaper, $ocr );
+     post_process_scan( [$gpage], $rotate, $unpaper_flag, $ocr );
     }
     return FALSE;    # uninstall
    }
diff --git a/lib/Gscan2pdf/Unpaper.pm b/lib/Gscan2pdf/Unpaper.pm
index 752d5b3..48cbd70 100644
--- a/lib/Gscan2pdf/Unpaper.pm
+++ b/lib/Gscan2pdf/Unpaper.pm
@@ -462,37 +462,41 @@ sub add_widget {
 }
 
 sub get_options {
- my ($self) = @_;
+ my ($self)  = @_;
  my $hashref = $self->{options};
- my $default;
+ my $default = $self->{default};
 
  foreach my $option ( keys %{$hashref} ) {
-  if ( $hashref->{$option}{type} eq 'ComboBox' ) {
-   my $i = $hashref->{$option}{widget}->get_active;
-   for ( keys %{ $hashref->{$option}{options} } ) {
-    $default->{$option} = $_
-      if ( $hashref->{$option}{options}{$_}{index} == $i );
+  if ( defined $hashref->{$option}{widget} ) {
+   if ( $hashref->{$option}{type} eq 'ComboBox' ) {
+    my $i = $hashref->{$option}{widget}->get_active;
+    for ( keys %{ $hashref->{$option}{options} } ) {
+     $default->{$option} = $_
+       if ( $hashref->{$option}{options}{$_}{index} == $i );
+    }
    }
-  }
-  elsif ( $hashref->{$option}{type} eq 'CheckButton' ) {
-   $default->{$option} = $hashref->{$option}{widget}->get_active ? TRUE : FALSE;
-  }
-  elsif ( $hashref->{$option}{type} eq 'SpinButton' ) {
-   $default->{$option} = $hashref->{$option}{widget}->get_value;
-  }
-  elsif ( $hashref->{$option}{type} eq 'CheckButtonGroup' ) {
-   my @items;
-   foreach ( keys %{ $hashref->{$option}{options} } ) {
-    push @items, $_ if ( $hashref->{$option}{options}{$_}{widget}->get_active );
+   elsif ( $hashref->{$option}{type} eq 'CheckButton' ) {
+    $default->{$option} =
+      $hashref->{$option}{widget}->get_active ? TRUE : FALSE;
    }
-   $default->{$option} = join ',', @items if (@items);
-  }
-  elsif ( $hashref->{$option}{type} eq 'SpinButtonGroup' ) {
-   my @items;
-   foreach ( keys %{ $hashref->{$option}{options} } ) {
-    push @items, $hashref->{$option}{options}{$_}{widget}->get_value;
+   elsif ( $hashref->{$option}{type} eq 'SpinButton' ) {
+    $default->{$option} = $hashref->{$option}{widget}->get_value;
+   }
+   elsif ( $hashref->{$option}{type} eq 'CheckButtonGroup' ) {
+    my @items;
+    foreach ( keys %{ $hashref->{$option}{options} } ) {
+     push @items, $_
+       if ( $hashref->{$option}{options}{$_}{widget}->get_active );
+    }
+    $default->{$option} = join ',', @items if (@items);
+   }
+   elsif ( $hashref->{$option}{type} eq 'SpinButtonGroup' ) {
+    my @items;
+    foreach ( keys %{ $hashref->{$option}{options} } ) {
+     push @items, $hashref->{$option}{options}{$_}{widget}->get_value;
+    }
+    $default->{$option} = join ',', @items if (@items);
    }
-   $default->{$option} = join ',', @items if (@items);
   }
  }
  return $default;
diff --git a/t/57_Gscan2pdf_Unpaper.t b/t/57_Gscan2pdf_Unpaper.t
index 7be7825..89d4269 100644
--- a/t/57_Gscan2pdf_Unpaper.t
+++ b/t/57_Gscan2pdf_Unpaper.t
@@ -1,6 +1,6 @@
 use warnings;
 use strict;
-use Test::More tests => 4;
+use Test::More tests => 5;
 
 BEGIN {
  use_ok('Gscan2pdf::Unpaper');
@@ -46,4 +46,16 @@ is_deeply(
  'get_options'
 );
 
+#########################
+
+$unpaper = Gscan2pdf::Unpaper->new(
+ {
+  'white-threshold' => '0.8',
+  'black-threshold' => '0.35',
+ },
+);
+
+is( $unpaper->get_cmdline, '--white-threshold 0.8 --black-threshold 0.35',
+ 'no GUI' );
+
 __END__
