Index: trunk/ippScripts/scripts/detrend_process_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 17937)
+++ trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 17941)
@@ -36,5 +36,5 @@
     'outroot|w=s'       => \$outroot, # output file base name
     'dbname|d=s'        => \$dbname, # Database name
-    'reduction=s'       => \$reduction,	# Reduction class
+    'reduction=s'       => \$reduction, # Reduction class
     'verbose'           => \$verbose,   # Print to stdout
     'no-update'         => \$no_update,
@@ -44,12 +44,12 @@
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
 pod2usage( -msg => "Required options: --det_id --exp_id --class_id --det_type --exp_tag --input_uri --camera --outroot",
-	   -exitval => 3) unless 
+           -exitval => 3) unless
     defined $det_id    and
-    defined $exp_id    and 
-    defined $class_id  and 
-    defined $det_type  and 
-    defined $exp_tag   and 
-    defined $input_uri and 
-    defined $camera    and 
+    defined $exp_id    and
+    defined $class_id  and
+    defined $det_type  and
+    defined $exp_tag   and
+    defined $input_uri and
+    defined $camera    and
     defined $outroot;
 
@@ -62,6 +62,6 @@
 
 # values to extract from output metadata and the stats to calculate
-my $STATS = 
-   [   
+my $STATS =
+   [
        #          PPSTATS KEYWORD         STATISTIC          CHIPTOOL FLAG
        { name => "ROBUST_MEDIAN",  type => "mean",  flag => "-bg",            dtype => "float" },
@@ -75,7 +75,7 @@
 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
-if ($missing_tools) { 
+if ($missing_tools) {
     warn("Can't find required tools.");
-    exit($PS_EXIT_CONFIG_ERROR); 
+    exit($PS_EXIT_CONFIG_ERROR);
 }
 $ppImage .= " -dbname $dbname" if defined $dbname;
@@ -105,10 +105,11 @@
     $command .= " -stats $outputStats";
     $command .= " -tracedest $traceDest -log $logDest";
+    $command .= " -dbname $dbname" if defined $dbname;
 
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => $verbose);
+        run(command => $command, verbose => $verbose);
     unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform ppImage: $error_code", $det_id, $exp_id, $class_id, $error_code);
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_id, $class_id, $error_code);
     }
 
@@ -119,5 +120,5 @@
 
     # Get the statistics on the processed image
-    my $statsFile;		# File handle
+    my $statsFile;              # File handle
     open $statsFile, $ipprc->file_resolve("$outputStats") or die "Can't open statistics file $outputStats: $!\n";
     my @contents = <$statsFile>; # Contents of file
@@ -125,5 +126,5 @@
 
     # parse the statistics MDC file
-    my $mdcParser = PS::IPP::Metadata::Config->new;	# Parser for metadata config files
+    my $mdcParser = PS::IPP::Metadata::Config->new;     # Parser for metadata config files
     my $metadata = $mdcParser->parse(join "", @contents)
         or &my_die("Unable to parse metadata config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR);
@@ -146,9 +147,9 @@
 unless ($no_update) {
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => $verbose);
+        run(command => $command, verbose => $verbose);
     unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	warn("Unable to perform dettool -addprocessedimfile: $error_code\n");
-	exit($error_code);
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        warn("Unable to perform dettool -addprocessedimfile: $error_code\n");
+        exit($error_code);
     }
 } else {
@@ -159,5 +160,5 @@
 {
     my $msg = shift; # Warning message on die
-    my $det_id = shift;		# Detrend identifier
+    my $det_id = shift;         # Detrend identifier
     my $exp_id = shift; # Exposure tag
     my $class_id = shift; # Class identifier
@@ -166,10 +167,10 @@
     carp($msg);
     if (defined $det_id and defined $exp_id and defined $class_id and not $no_update) {
-	my $command = "$dettool -addprocessedimfile";
-	$command .= " -det_id $det_id";
-	$command .= " -exp_id $exp_id"; 
-	$command .= " -class_id $class_id";
-	$command .= " -code $exit_code";
-	$command .= " -dbname $dbname" if defined $dbname;
+        my $command = "$dettool -addprocessedimfile";
+        $command .= " -det_id $det_id";
+        $command .= " -exp_id $exp_id";
+        $command .= " -class_id $class_id";
+        $command .= " -code $exit_code";
+        $command .= " -dbname $dbname" if defined $dbname;
         system ($command);
     }
Index: trunk/ippScripts/scripts/detrend_resid.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_resid.pl	(revision 17937)
+++ trunk/ippScripts/scripts/detrend_resid.pl	(revision 17941)
@@ -39,5 +39,5 @@
     'outroot|w=s'       => \$outroot,   # output file base name
     'dbname|d=s'        => \$dbname, # Database name
-    'reduction=s'       => \$reduction,	# Reduction class
+    'reduction=s'       => \$reduction, # Reduction class
     'verbose'           => \$verbose,   # Print to stdout
     'no-update'         => \$no_update,
@@ -47,15 +47,15 @@
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
 pod2usage( -msg => "Required options: --det_id --iteration --exp_id --exp_tag --class_id --det_type --camera --input_uri --mode --detrend --outroot (not for 'verify' mode)",
-	   -exitval => 3) unless 
-    defined $det_id    and 
-    defined $iter      and 
-    defined $exp_id    and 
-    defined $exp_tag   and 
-    defined $class_id  and 
-    defined $det_type  and 
-    defined $input_uri and 
-    defined $camera    and 
-    defined $mode      and 
-    defined $outroot   and 
+           -exitval => 3) unless
+    defined $det_id    and
+    defined $iter      and
+    defined $exp_id    and
+    defined $exp_tag   and
+    defined $class_id  and
+    defined $det_type  and
+    defined $input_uri and
+    defined $camera    and
+    defined $mode      and
+    defined $outroot   and
     (defined $detrend or lc($mode) eq 'verify');
 
@@ -64,5 +64,5 @@
 # Recipes to use as a function of detrend type and mode
 $reduction = 'DETREND' unless defined $reduction;
-my $recipe;			# Name of recipe to use
+my $recipe;                     # Name of recipe to use
 if ($mode eq 'master') {
     $recipe = uc($det_type) . '_RESID';
@@ -75,15 +75,15 @@
 
 # values to extract from output metadata and the stats to calculate
-my $STATS = 
+my $STATS =
    [
        #          PPSTATS KEYWORD         STATISTIC          CHIPTOOL FLAG
        { name => "ROBUST_MEDIAN",      type => "mean",  flag => "-bg",             dtype => "float" },
        { name => "ROBUST_MEDIAN",      type => "stdev", flag => "-bg_mean_stdev",  dtype => "float" },
-       { name => "ROBUST_STDEV",       type => "rms",   flag => "-bg_stdev",	   dtype => "float" },
+       { name => "ROBUST_STDEV",       type => "rms",   flag => "-bg_stdev",       dtype => "float" },
        { name => "SAMPLE_SKEWNESS",    type => "mean",  flag => "-bg_skewness",    dtype => "float" },
        { name => "SAMPLE_KURTOSIS",    type => "mean",  flag => "-bg_kurtosis",    dtype => "float" },
-       { name => "FRINGE_0",           type => "mean",  flag => "-fringe_0",	   dtype => "float" },
-       { name => "FRINGE_ERR_0",       type => "rms",   flag => "-fringe_1",	   dtype => "float" },
-       { name => "FRINGE_0",           type => "stdev", flag => "-fringe_2",	   dtype => "float" },
+       { name => "FRINGE_0",           type => "mean",  flag => "-fringe_0",       dtype => "float" },
+       { name => "FRINGE_ERR_0",       type => "rms",   flag => "-fringe_1",       dtype => "float" },
+       { name => "FRINGE_0",           type => "stdev", flag => "-fringe_2",       dtype => "float" },
        { name => "FRINGE_RESID_0",     type => "mean",  flag => "-fringe_resid_0", dtype => "float" },
        { name => "FRINGE_RESID_ERR_0", type => "rms",   flag => "-fringe_resid_1", dtype => "float" },
@@ -92,5 +92,5 @@
 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser
 
-my $BINNED_STATS = 
+my $BINNED_STATS =
    [
        { name => "ROBUST_STDEV",   type => "rms",   flag => "-bin_stdev" },
@@ -100,17 +100,17 @@
 # Flags to specify the particular detrend to use
 use constant DETRENDS => {
-    'bias'     => '-bias',	# Specify the bias frame
-    'dark'     => '-dark',	# Specify the dark frame
-    'shutter'  => '-shutter',	# Specify the shutter frame
-    'flat'     => '-flat',	# Specify the flat frame
-    'domeflat' => '-flat',	# Specify the flat frame
-    'skyflat'  => '-flat',	# Specify the flat frame
-    'fringe'   => '-fringe',	# Specify the fringe frame
-    'mask'     => '-mask',	# Specify the mask frame
-    'darkmask' => '-mask',	# Specify the mask frame
-    'flatmask' => '-mask',	# Specify the mask frame
+    'bias'     => '-bias',      # Specify the bias frame
+    'dark'     => '-dark',      # Specify the dark frame
+    'shutter'  => '-shutter',   # Specify the shutter frame
+    'flat'     => '-flat',      # Specify the flat frame
+    'domeflat' => '-flat',      # Specify the flat frame
+    'skyflat'  => '-flat',      # Specify the flat frame
+    'fringe'   => '-fringe',    # Specify the fringe frame
+    'mask'     => '-mask',      # Specify the mask frame
+    'darkmask' => '-mask',      # Specify the mask frame
+    'flatmask' => '-mask',      # Specify the mask frame
 };
 
-use constant DELETE_STATS => 0;	# Delete the statistics file when done?
+use constant DELETE_STATS => 0; # Delete the statistics file when done?
 
 # Look for programs we need
@@ -119,7 +119,7 @@
 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
 my $ppStats = can_run('ppStats') or (warn "Can't find ppStats" and $missing_tools = 1);
-if ($missing_tools) { 
+if ($missing_tools) {
     warn("Can't find required tools.");
-    exit($PS_EXIT_CONFIG_ERROR); 
+    exit($PS_EXIT_CONFIG_ERROR);
 }
 $ppImage .= " -dbname $dbname" if defined $dbname;
@@ -147,17 +147,18 @@
     $command .= " -stats $outputStats";
     $command .= " -tracedest $traceDest -log $logDest";
+    $command .= " -dbname $dbname" if defined $dbname;
 
     # Detrend to use in processing
     if (lc($mode) ne 'verify') {
-	my $detFlag = DETRENDS->{lc($det_type)};
-	&my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_PROG_ERROR) unless defined $detFlag;
-	$command .= " $detFlag $detrend";
+        my $detFlag = DETRENDS->{lc($det_type)};
+        &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_PROG_ERROR) unless defined $detFlag;
+        $command .= " $detFlag $detrend";
     }
 
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => $verbose);
+        run(command => $command, verbose => $verbose);
     unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $exp_id, $class_id, $error_code);
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        &my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $exp_id, $class_id, $error_code);
     }
     &my_die("Couldn't find expected output file: $outputName", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputName);
@@ -167,5 +168,5 @@
 
     # Load the raw output stats file
-    my $statsFile;		# File handle
+    my $statsFile;              # File handle
     open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_SYS_ERROR);
     my @contents = <$statsFile>; # Contents of file
@@ -173,5 +174,5 @@
 
     # Parse the stats file contents into a metadata
-    my $mdcParser = PS::IPP::Metadata::Config->new;	# Parser for metadata config files
+    my $mdcParser = PS::IPP::Metadata::Config->new;     # Parser for metadata config files
     my $metadata = $mdcParser->parse(join "", @contents) or &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_PROG_ERROR);
 
@@ -182,8 +183,8 @@
     $command = "$ppStats -recipe PPSTATS RESIDUAL $bin2Name";
     ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => $verbose);
+        run(command => $command, verbose => $verbose);
     unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform ppStats: $error_code", $det_id, $iter, $exp_id, $class_id, $error_code);
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        &my_die("Unable to perform ppStats: $error_code", $det_id, $iter, $exp_id, $class_id, $error_code);
     }
 
@@ -211,9 +212,9 @@
 unless ($no_update) {
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => $verbose);
+        run(command => $command, verbose => $verbose);
     unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	warn("Unable to perform dettool -addresidimfile: $error_code\n");
-	exit($error_code);
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        warn("Unable to perform dettool -addresidimfile: $error_code\n");
+        exit($error_code);
     }
 } else {
@@ -224,6 +225,6 @@
 {
     my $msg = shift; # Warning message on die
-    my $det_id = shift;		# Detrend identifier
-    my $iter = shift;		# Iteration
+    my $det_id = shift;         # Detrend identifier
+    my $iter = shift;           # Iteration
     my $exp_id = shift; # Exposure tag
     my $class_id = shift; # Class identifier
@@ -232,11 +233,11 @@
     carp($msg);
     if (defined $det_id and defined $iter and defined $exp_id and not $no_update) {
-	my $command = "$dettool -addresidimfile";
-	$command .= " -det_id $det_id";
-	$command .= " -iteration $iter";
-	$command .= " -exp_id $exp_id";
-	$command .= " -class_id $class_id";
-	$command .= " -code $exit_code";
-	$command .= " -dbname $dbname" if defined $dbname;
+        my $command = "$dettool -addresidimfile";
+        $command .= " -det_id $det_id";
+        $command .= " -iteration $iter";
+        $command .= " -exp_id $exp_id";
+        $command .= " -class_id $class_id";
+        $command .= " -code $exit_code";
+        $command .= " -dbname $dbname" if defined $dbname;
         system ($command);
     }
Index: trunk/ippScripts/scripts/detrend_stack.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_stack.pl	(revision 17937)
+++ trunk/ippScripts/scripts/detrend_stack.pl	(revision 17941)
@@ -36,5 +36,5 @@
     'outroot|w=s'       => \$outroot,   # output file base name
     'dbname|d=s'        => \$dbname, # Database name
-    'reduction=s'       => \$reduction,	# Reduction class for processing
+    'reduction=s'       => \$reduction, # Reduction class for processing
     'verbose'           => \$verbose,   # Print to stdout
     'save-temps'        => \$save_temps, # Save temporary files?
@@ -44,10 +44,10 @@
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
-pod2usage( -msg => "Required options: --det_id --iteration --class_id --det_type --camera --outroot", 
-	   -exitval => 3) unless 
-    defined $det_id   and 
-    defined $iter     and 
-    defined $class_id and 
-    defined $det_type and 
+pod2usage( -msg => "Required options: --det_id --iteration --class_id --det_type --camera --outroot",
+           -exitval => 3) unless
+    defined $det_id   and
+    defined $iter     and
+    defined $class_id and
+    defined $det_type and
     defined $camera   and
     defined $outroot;
@@ -64,6 +64,6 @@
 # XXX -bg_mean_stdev should take stdev of bg_mean if bg_mean_stdev == 0     (B)
 # XXX  (A) if imfile.Ncomp > 1, (B) if imfile.Ncomp == 1
-my $STATS = 
-   [   
+my $STATS =
+   [
        #          KEYWORD                 STATISTIC          CHIPTOOL FLAG
        { name => "ROBUST_MEDIAN",  type => "mean",  flag => "-bg",             dtype => "float" },
@@ -77,21 +77,21 @@
 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
 my $ppMerge = can_run('ppMerge') or (warn "Can't find ppMerge" and $missing_tools = 1);
-if ($missing_tools) { 
+if ($missing_tools) {
     warn("Can't find required tools.");
-    exit($PS_EXIT_CONFIG_ERROR); 
+    exit($PS_EXIT_CONFIG_ERROR);
 }
 
 # The output file rule name depends on the detrend type
 my $FILERULES = { 'FLATMASK' => 'PPMERGE.OUTPUT.MASK',
-		  'DARKMASK' => 'PPMERGE.OUTPUT.MASK',
-		  'MASK'     => 'PPMERGE.OUTPUT.MASK',
-		  'BIAS'     => 'PPMERGE.OUTPUT.BIAS',
-		  'DARK'     => 'PPMERGE.OUTPUT.DARK',
-		  'SHUTTER'  => 'PPMERGE.OUTPUT.SHUTTER',
-		  'FLAT'     => 'PPMERGE.OUTPUT.FLAT',
-		  'DOMEFLAT' => 'PPMERGE.OUTPUT.FLAT',
-		  'SKYFLAT'  => 'PPMERGE.OUTPUT.FLAT',
-		  'FRINGE'   => 'PPMERGE.OUTPUT.FRINGE',
-	      };
+                  'DARKMASK' => 'PPMERGE.OUTPUT.MASK',
+                  'MASK'     => 'PPMERGE.OUTPUT.MASK',
+                  'BIAS'     => 'PPMERGE.OUTPUT.BIAS',
+                  'DARK'     => 'PPMERGE.OUTPUT.DARK',
+                  'SHUTTER'  => 'PPMERGE.OUTPUT.SHUTTER',
+                  'FLAT'     => 'PPMERGE.OUTPUT.FLAT',
+                  'DOMEFLAT' => 'PPMERGE.OUTPUT.FLAT',
+                  'SKYFLAT'  => 'PPMERGE.OUTPUT.FLAT',
+                  'FRINGE'   => 'PPMERGE.OUTPUT.FRINGE',
+              };
 my $output_filerule = $FILERULES->{$det_type}; # File rule for output
 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless defined $output_filerule;
@@ -107,15 +107,15 @@
 
     ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => $verbose);
+        run(command => $command, verbose => $verbose);
     unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform dettool -processedimfile: $error_code", $det_id, $iter, $class_id, $error_code);
-    }
-
-    my $mdcParser = PS::IPP::Metadata::Config->new;	# Parser for metadata config files
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        &my_die("Unable to perform dettool -processedimfile: $error_code", $det_id, $iter, $class_id, $error_code);
+    }
+
+    my $mdcParser = PS::IPP::Metadata::Config->new;     # Parser for metadata config files
     my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
-	&my_die("Unable to parse metadata config doc", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR);
-    $files = parse_md_list($metadata) or 
-	&my_die("Unable to parse metadata list", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR);
+        &my_die("Unable to parse metadata config doc", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR);
+    $files = parse_md_list($metadata) or
+        &my_die("Unable to parse metadata list", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR);
 }
 
@@ -129,5 +129,5 @@
     $num++;
 
-    my $image = $file->{uri};	# Image name
+    my $image = $file->{uri};   # Image name
     my $mask = $ipprc->filename( "PPIMAGE.OUTPUT.MASK", $file->{path_base}, $class_id ); # Mask name
     my $weight = $ipprc->filename( "PPIMAGE.OUTPUT.WEIGHT", $file->{path_base}, $class_id ); # Weight name
@@ -137,8 +137,8 @@
 
     if ($ipprc->file_exists( $mask )) {
-	print $listFile "\tMASK\tSTR\t" . $mask . "\n";
+        print $listFile "\tMASK\tSTR\t" . $mask . "\n";
     }
     if ($ipprc->file_exists( $weight )) {
-	print $listFile "\tWEIGHT\tSTR\t" . $weight . "\n";
+        print $listFile "\tWEIGHT\tSTR\t" . $weight . "\n";
     }
 
@@ -166,15 +166,16 @@
 $command .= " -recipe PPMERGE $recipe";
 $command .= ' -type ' . uc($det_type); # Type of stacking to perform
-$command .= " -stats $outputStats";	# Statistics output filename
+$command .= " -stats $outputStats";     # Statistics output filename
 $command .= " -recipe PPSTATS CHIPSTATS";
 $command .= " -tracedest $traceDest -log $logDest";
+$command .= " -dbname $dbname" if defined $dbname;
 
 # Stack the files
 unless ($no_op) {
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => $verbose);
+        run(command => $command, verbose => $verbose);
     unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform ppMerge: $error_code", $det_id, $iter, $class_id, $error_code);
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        &my_die("Unable to perform ppMerge: $error_code", $det_id, $iter, $class_id, $error_code);
     }
     &my_die("Unable to find expected output file: $outputStack\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStack);
@@ -185,14 +186,14 @@
     # Get the statistics on the stacked image
     open(my $statsFile, $ipprc->file_resolve("$outputStats")) or
-	&my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR);
+        &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR);
     my $contents = do { local $/; <$statsFile> }; # Contents of file
     close($statsFile);
-    
-    my $mdcParser = PS::IPP::Metadata::Config->new;	# Parser for metadata config files
+
+    my $mdcParser = PS::IPP::Metadata::Config->new;     # Parser for metadata config files
     my $metadata = $mdcParser->parse($contents) or
-	&my_die("Unable to parse metadata config doc", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR);
+        &my_die("Unable to parse metadata config doc", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR);
 
     $stats->parse($metadata)  or
-	&my_die("Unable to find all values in statistics output.", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR);
+        &my_die("Unable to find all values in statistics output.", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR);
 }
 
@@ -209,9 +210,9 @@
 unless ($no_update) {
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => $verbose);
+        run(command => $command, verbose => $verbose);
     unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	warn("Unable to perform dettool -addstacked: $error_code\n");
-	exit($error_code);
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        warn("Unable to perform dettool -addstacked: $error_code\n");
+        exit($error_code);
     }
 } else {
@@ -222,6 +223,6 @@
 {
     my $msg = shift; # Warning message on die
-    my $det_id = shift;		# Detrend identifier
-    my $iter = shift;		# Iteration
+    my $det_id = shift;         # Detrend identifier
+    my $iter = shift;           # Iteration
     my $class_id = shift; # Class identifier
     my $exit_code = shift; # Exit code to add
@@ -229,11 +230,11 @@
     carp($msg);
     if (defined $det_id and defined $iter and defined $class_id and not $no_update) {
-	my $command = "$dettool -addstacked";
-	$command .= " -det_id $det_id";
-	$command .= " -iteration $iter";
-	$command .= " -class_id $class_id";
-	$command .= " -code $exit_code";
-	$command .= " -dbname $dbname" if defined $dbname;
-	system ($command);
+        my $command = "$dettool -addstacked";
+        $command .= " -det_id $det_id";
+        $command .= " -iteration $iter";
+        $command .= " -class_id $class_id";
+        $command .= " -code $exit_code";
+        $command .= " -dbname $dbname" if defined $dbname;
+        system ($command);
     }
     exit $exit_code;
