Index: branches/eam_branches/ipp-20110213/ippScripts/scripts/diff_skycell.pl
===================================================================
--- branches/eam_branches/ipp-20110213/ippScripts/scripts/diff_skycell.pl	(revision 30812)
+++ branches/eam_branches/ipp-20110213/ippScripts/scripts/diff_skycell.pl	(revision 31083)
@@ -68,8 +68,19 @@
 my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $diff_id, $skycell_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
 
-# XXX camera is not known here; cannot use filerules...
+my $neb;
+my $scheme = file_scheme($outroot);
+if ($scheme and $scheme eq 'neb') {
+    $neb = $ipprc->nebulous();
+}
+
+# XXX camera is not known here; cannot use filerules... 
+# bills 2011-03-07 This is unfortunate because it prevents us from using prepare_output ...
 # my $logDest = $ipprc->filename("LOG.EXP", $outroot);
 my $logDest = "$outroot.log";
-$logDest .= ".update" if $run_state eq "update";
+if ($run_state eq 'update') {
+    $logDest .= '.update';
+    # ... well we can just do the dirty work here
+    $ipprc->kill_file($logDest);
+}
 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR ) if $redirect;
 
@@ -137,5 +148,5 @@
                 $templateVariance = "PPSTACK.UNCONV.VARIANCE";
             }
-            $templateSources = "PSPHOT.OUT.CMF.MEF";  ## this must be consistent with the value in stack_skycell.pl:161
+            $templateSources = "PSPHOT.OUT.CMF.MEF";  ## this must be consistent with the value in stack_skycell.pl
             # template is a stack so it doesn't need to be magicked
             $templateMagic = 1;
@@ -163,5 +174,5 @@
                 $inputVariance = "PPSTACK.UNCONV.VARIANCE";
             }
-            $inputSources = "PSPHOT.OUT.CMF.MEF";  ## this must be consistent with the value in stack_skycell.pl:161
+            $inputSources = "PSPHOT.OUT.CMF.MEF";  ## this must be consistent with the value in stack_skycell.pl
         } else {
             $input     = "PSWARP.OUTPUT";
@@ -249,27 +260,41 @@
 
 # Get the output filenames
-my $outputName = $ipprc->filename("PPSUB.OUTPUT", $outroot);
-my $outputMask = $ipprc->filename("PPSUB.OUTPUT.MASK", $outroot);
-my $outputVariance = $ipprc->filename("PPSUB.OUTPUT.VARIANCE", $outroot);
-my $outputSources = $ipprc->filename("PPSUB.OUTPUT.SOURCES", $outroot);
-my $jpeg1Name = $ipprc->filename("PPSUB.OUTPUT.JPEG1", $outroot);
-my $jpeg2Name = $ipprc->filename("PPSUB.OUTPUT.JPEG2", $outroot);
-my $configuration = $ipprc->filename("PPSUB.CONFIG", $outroot);
-my $outputStats = $ipprc->filename("SKYCELL.STATS", $outroot);
-my $traceDest = $ipprc->filename("TRACE.EXP", $outroot);
-
-if ($run_state eq 'update') {
-    $traceDest .= '.update';
-    $outputStats .= '.update';
-
+my $configuration;
+my $outputStats;
+my $traceDest;
+my $do_photom = 1;
+my $dump_config = 1; 
+if ($run_state eq 'new') {
+    $configuration = prepare_output("PPSUB.CONFIG", $outroot, 1);
+    $traceDest = prepare_output("TRACE.EXP", $outroot, 1);
+    $outputStats = prepare_output("SKYCELL.STATS", $outroot, 1);
+} else {
+    $do_photom = 0;
+    $dump_config = 0;
+    $traceDest = prepare_output("TRACE.EXP.UPDATE", $outroot, 1);
+    # we rerun stats because we need the quality value
+    $outputStats = prepare_output("SKYCELL.STATS.UPDATE", $outroot, 1);
+    $configuration = $ipprc->filename("PPSUB.CONFIG", $outroot);
+    if (!$ipprc->file_exists($configuration)) {
+       print STDERR "WARNING: Config dump file $configuration is missing. Using current recipes and file rules.\n";
+       $configuration = undef;
+    }
+    # use WARPSTATS if we're updating, as we don't care about the new stuff from the STACK and DIFF STATS recipes
     $recipe_ppstats = 'WARPSTATS';
 }
+
+my $outputName = prepare_output("PPSUB.OUTPUT", $outroot, 1);
+my $outputMask = prepare_output("PPSUB.OUTPUT.MASK", $outroot, 1);
+my $outputVariance = prepare_output("PPSUB.OUTPUT.VARIANCE", $outroot, 1);
+my $outputSources = prepare_output("PPSUB.OUTPUT.SOURCES", $outroot, 1) if $do_photom;
+my $jpeg1Name = prepare_output("PPSUB.OUTPUT.JPEG1", $outroot, 1);
+my $jpeg2Name = prepare_output("PPSUB.OUTPUT.JPEG2", $outroot, 1);
 
 my ($inverseName, $inverseMask, $inverseVariance, $inverseSources);
 if ($inverse) {
-    $inverseName = $ipprc->filename("PPSUB.INVERSE", $outroot);
-    $inverseMask = $ipprc->filename("PPSUB.INVERSE.MASK", $outroot);
-    $inverseVariance = $ipprc->filename("PPSUB.INVERSE.VARIANCE", $outroot);
-    $inverseSources = $ipprc->filename("PPSUB.INVERSE.SOURCES", $outroot);
+    $inverseName = prepare_output("PPSUB.INVERSE", $outroot, 1);
+    $inverseMask = prepare_output("PPSUB.INVERSE.MASK", $outroot, 1);
+    $inverseVariance = prepare_output("PPSUB.INVERSE.VARIANCE", $outroot, 1);
+    $inverseSources = prepare_output("PPSUB.INVERSE.SOURCES", $outroot, 1) if $do_photom;
 }
 
@@ -289,9 +314,8 @@
     $command .= " -stats $outputStats";
     $command .= " -threads $threads" if defined $threads;
-    if ($run_state eq "new") {
+    if ($dump_config) {
         $command .= " -dumpconfig $configuration";
-    } else {
-        my $configurationReal = $ipprc->file_resolve($configuration) or &my_die("Couldn't resolve configuration file: $configuration", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR);
-        $command .= " -ipprc $configurationReal";
+    } elsif ($configuration) {
+        $command .= " -ipprc $configuration";
     }
     $command .= " -save-inconv" if defined $saveInConv and $run_state eq "new";
@@ -303,5 +327,5 @@
     $command .= " -F PSPHOT.OUTPUT PSPHOT.OUT.CMF.MEF";
     $command .= " -F PSPHOT.BACKMDL PSPHOT.BACKMDL.MEF";
-    if ($run_state eq "new") {
+    if ($do_photom) {
         $command .= " -photometry";
     } else {
@@ -322,6 +346,6 @@
         }
 
+        check_output($outputStats, 1);
         my $outputStatsReal = $ipprc->file_resolve($outputStats);
-        &my_die("Couldn't find expected output file: $outputStats", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStatsReal);
 
         # measure chip stats
@@ -341,17 +365,17 @@
 
         if (!$quality) {
-            &my_die("Couldn't find expected output file: $outputName", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputName);
-            &my_die("Couldn't find expected output file: $outputMask", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);
-            &my_die("Couldn't find expected output file: $outputVariance", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputVariance);
-            &my_die("Couldn't find expected output file: $outputSources", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);
-            &my_die("Couldn't find expected output file: $jpeg1Name",    $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($jpeg1Name);
-            &my_die("Couldn't find expected output file: $jpeg2Name",    $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($jpeg2Name);
+            check_output($outputName, 0);
+            check_output($outputMask, 0);
+            check_output($outputVariance, 0);
+            check_output($outputSources, 1) if $do_photom;
+            check_output($jpeg1Name, 1);
+            check_output($jpeg2Name, 1);
             if ($inverse) {
-                &my_die("Couldn't find expected output file: $inverseName", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inverseName);
-                &my_die("Couldn't find expected output file: $inverseMask", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inverseMask);
-                &my_die("Couldn't find expected output file: $inverseVariance", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inverseVariance);
-                &my_die("Couldn't find expected output file: $inverseSources", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inverseSources);
+                check_output($inverseName, 0);
+                check_output($inverseMask, 0);
+                check_output($inverseVariance, 0);
+                check_output($inverseSources, 1) if $do_photom;
                 if ($run_state eq 'new') {
-                    &my_die("Couldn't find expected output file: $configuration", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($configuration);
+                    check_output($configuration, 1);
                 }
             }
@@ -391,4 +415,39 @@
     }
 }
+exit 0;
+
+
+# Prepare to write to an output file
+#   Lookup the filename in the rules.
+#   Make sure that if file exists and is a nebulous file that there is only one instance
+#   Deal with files that have been lost.
+sub prepare_output
+{
+    my $filerule = shift;
+    my $outroot  = shift;
+    my $delete = shift;
+    $delete = 0 if !defined $delete;
+
+    my $error;
+    my $output = $ipprc->prepare_output($filerule, $outroot, undef, $delete, \$error)
+                    or &my_die("failed to prepare output file for: $filerule", $diff_id, $skycell_id, $error);
+    return $output;
+}
+
+sub check_output
+{
+    my $file = shift;
+    my $replicate = shift;
+
+    if (!defined $file) {
+        return;
+    }
+
+    &my_die("Couldn't find expected output file: $file",  $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file);
+
+    if ($replicate and $neb) {
+        $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n",  $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR);
+    }
+}
 
 
Index: branches/eam_branches/ipp-20110213/ippScripts/scripts/dist_bundle.pl
===================================================================
--- branches/eam_branches/ipp-20110213/ippScripts/scripts/dist_bundle.pl	(revision 30812)
+++ branches/eam_branches/ipp-20110213/ippScripts/scripts/dist_bundle.pl	(revision 31083)
@@ -70,5 +70,5 @@
 
 # Parse the command-line arguments
-my ($camera, $stage, $stage_id, $component, $path_base, $chip_path_base, $alt_path_base, $clean);
+my ($camera, $stage, $stage_id, $component, $path_base, $chip_path_base, $alt_path_base, $clean, $exp_type);
 my ($outroot, $run_state, $data_state, $magicked, $no_magic, $poor_quality, $results_file, $prefix);
 my ($dbname, $save_temps, $verbose, $no_update, $logfile);
@@ -89,4 +89,5 @@
            'alt_path_base=s'=> \$alt_path_base,  # path to alternate inputs
            'outroot=s'      => \$outroot,    # outroot
+           'exp_type=s'     => \$exp_type,   # exp_type (only used for raw stage
            'prefix=s'       => \$prefix,     # "prefix" to apply to filenames
            'clean'          => \$clean,      # create clean distribution
@@ -99,5 +100,5 @@
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
-pod2usage( -msg => "Required options: --camera --stage --stage_id --component --path_base --outroot",
+pod2usage( -msg => "Required options: --camera --stage --stage_id --component --exp_type --path_base --outroot",
            -exitval => 3) unless
     defined $camera and
@@ -105,4 +106,5 @@
     defined $stage_id and
     defined $component and
+    defined $exp_type and
     defined $path_base and
     defined $outroot;
@@ -110,6 +112,9 @@
 $ipprc->redirect_output($logfile) if $logfile;
 
-if (($stage eq 'raw') and !$clean and !defined $chip_path_base) {
-    pod2usage( -msg => "Required options: --chip_path_base for raw stage", -exitval => 3);
+if ($stage eq 'raw' and !$clean and !$no_magic) {
+    # need to be able to find chip mask file
+    if ($exp_type eq 'OBJECT' and !defined $chip_path_base) {
+        pod2usage( -msg => "Required options: --chip_path_base for raw stage", -exitval => 3);
+    }
 }
 
@@ -123,5 +128,5 @@
 my $file_list = get_file_list($stage, $component, $path_base, $clean);
 
-if (($stage ne 'raw') and ($stage ne 'fake')) {
+if (($stage ne 'raw') and ($stage ne 'fake') and !$poor_quality) {
     # If the file list is empty it is an error because we should at least get a config dump file
     # except for fake stage which doesn't do anything yet
@@ -493,8 +498,10 @@
             push @file_list, \%image;
 
-            my %burntool_table;
-            $burntool_table{file_rule} = "BURNTOOL.TABLE";
-            $burntool_table{name} = "$path_base.burn.tbl";
-            push @file_list, \%burntool_table;
+            if ($exp_type eq 'OBJECT' and $camera eq 'GPC1') {
+                my %burntool_table;
+                $burntool_table{file_rule} = "BURNTOOL.TABLE";
+                $burntool_table{name} = "$path_base.burn.tbl";
+                push @file_list, \%burntool_table;
+            }
         }
         return \@file_list;
@@ -541,4 +548,8 @@
     my $resolved = $ipprc->file_resolve($config_file);
 
+    if (!$resolved and $poor_quality) {
+        print STDERR "non config file found but continuing since component has poor quality\n";
+        return undef
+    }
     &my_die("failed to resolve name of config dump file: $config_file_rule", $component,
                     $PS_EXIT_CONFIG_ERROR) if (!$resolved);
Index: branches/eam_branches/ipp-20110213/ippScripts/scripts/dist_component.pl
===================================================================
--- branches/eam_branches/ipp-20110213/ippScripts/scripts/dist_component.pl	(revision 30812)
+++ branches/eam_branches/ipp-20110213/ippScripts/scripts/dist_component.pl	(revision 31083)
@@ -37,5 +37,5 @@
 # Parse the command-line arguments
 my ($dist_id, $camera, $stage, $stage_id, $component, $path_base, $chip_path_base, $clean, $alt_path_base);
-my ($outdir, $run_state, $data_state, $magicked, $no_magic, $poor_quality);
+my ($outdir, $run_state, $data_state, $magicked, $no_magic, $poor_quality, $exp_type);
 my ($dbname, $save_temps, $verbose, $no_update, $logfile);
 
@@ -53,4 +53,5 @@
            'no_magic'       => \$no_magic,   # magic is not required for this distribution run
            'magicked'       => \$magicked,   # magicked state for this component
+           'exp_type=s'     => \$exp_type,
            'alt_path_base=s'=> \$alt_path_base,  # path to alternate inputs
            'outdir=s'       => \$outdir,     # "directory" for outputs
@@ -81,6 +82,6 @@
 $temproot = "/tmp" if !defined $temproot;
 
-if (($stage eq 'raw') and !$clean and !defined $chip_path_base) {
-    pod2usage( -msg => "Required options: --chip_path_base for raw stage", -exitval => 3);
+if (($stage eq 'raw') and !$clean and !(defined $chip_path_base and defined $exp_type)) {
+    pod2usage( -msg => "Required options: --chip_path_base --exp_type for raw stage", -exitval => 3);
 }
 
@@ -105,4 +106,5 @@
     $command .= " --magicked" if defined $magicked;
     $command .= " --alt_path_base $alt_path_base" if defined $alt_path_base;
+    $command .= " --exp_type $exp_type" if defined $exp_type;
     $command .= " --clean" if defined $clean;
     $command .= " --save-temps" if defined $save_temps;
Index: branches/eam_branches/ipp-20110213/ippScripts/scripts/ipp_apply_burntool_single.pl
===================================================================
--- branches/eam_branches/ipp-20110213/ippScripts/scripts/ipp_apply_burntool_single.pl	(revision 30812)
+++ branches/eam_branches/ipp-20110213/ippScripts/scripts/ipp_apply_burntool_single.pl	(revision 31083)
@@ -131,4 +131,5 @@
 	run ( command => $regtool_status_cmd, verbose => $verbose );
     unless ($success) {
+	print "Unsuccessful at running regtool -checkstatus, aborting continue\n";
 	$continue = 0;
     }
@@ -237,4 +238,5 @@
 	$command .= " -set_state full ";
     }
+	
     $status = vsystem ($command, $REALRUN);
     if ($status) {
Index: branches/eam_branches/ipp-20110213/ippScripts/scripts/ipp_cleanup.pl
===================================================================
--- branches/eam_branches/ipp-20110213/ippScripts/scripts/ipp_cleanup.pl	(revision 30812)
+++ branches/eam_branches/ipp-20110213/ippScripts/scripts/ipp_cleanup.pl	(revision 31083)
@@ -130,8 +130,10 @@
         $status = 0 unless defined $path_base and $path_base ne "NULL";
 
+        my $poor_quality = $imfile->{quality} > 0;
+
         # don't clean up unless the data needed to update is available
         # modes goto_purged and goto_scrubbed will remove files even if the config is non-existent
         # goto_scrubbed now requires the config file to not exist.
-        if ($status) {
+        if ($status and !$poor_quality) {
             if ($mode eq "goto_cleaned") {
                 my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base, $class_id);
@@ -1902,5 +1904,5 @@
 
     foreach my $file (@$files) {
-        print STDERR "unlinking $stage $stage_id $file";
+        print STDERR "unlinking $stage $stage_id $file\n";
 
         my $error_code = $ipprc->kill_file($file);
Index: branches/eam_branches/ipp-20110213/ippScripts/scripts/magic_destreak_revert.pl
===================================================================
--- branches/eam_branches/ipp-20110213/ippScripts/scripts/magic_destreak_revert.pl	(revision 30812)
+++ branches/eam_branches/ipp-20110213/ippScripts/scripts/magic_destreak_revert.pl	(revision 31083)
@@ -204,5 +204,5 @@
 
     # only revert sources if this is a new run, not one being updated
-    if ($run_state eq 'new') {
+    if (($run_state eq 'new') or ($run_state eq 'goto_restored')) {
         $sources = $ipprc->filename("PSPHOT.OUTPUT", $path_base, $class_id);
         $bsources = $ipprc->filename("PSPHOT.OUTPUT", $backup_path_base, $class_id);
Index: branches/eam_branches/ipp-20110213/ippScripts/scripts/minidvodb_merge.pl
===================================================================
--- branches/eam_branches/ipp-20110213/ippScripts/scripts/minidvodb_merge.pl	(revision 30812)
+++ branches/eam_branches/ipp-20110213/ippScripts/scripts/minidvodb_merge.pl	(revision 31083)
@@ -16,4 +16,6 @@
 my $dtime_relphot;
 my $dtime_merge;
+my $dtime_verify;
+my $dtime_script;
 
 use vars qw( $VERSION );
@@ -36,4 +38,7 @@
 my $relphot = can_run('relphot') or (warn "Can't find relphot" and $missing_tools = 1);
 my $relastro = can_run('relastro') or (warn "Can't find relastro" and $missing_tools = 1);
+my $dvoverify = can_run('dvoverify') or (warn "Can't find dvoverify" and $missing_tools = 1);
+
+
 if ($missing_tools) {
     warn("Can't find required tools.");
@@ -87,4 +92,9 @@
 unless ($no_op) {
     if (defined $mergedvodbReal) {
+
+	#this is chopped into several parts:  addstar, relphot, dvoverify, merge
+
+
+	#addstar
         {
             my $command  = "$addstar -resort";
@@ -105,4 +115,6 @@
             print "addstar -resort time $dtime_addstar\n";
         }
+
+	#relphot
 
         {
@@ -124,4 +136,22 @@
             print "relphot time $dtime_relphot\n";
         }
+	#dvoverify
+	{
+            my $command  = "$dvoverify -s $minidvodb";
+            print "$command\n";
+            my $mjd_dvoverify_start = DateTime->now->mjd;   # MJD of starting script
+
+            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+                run(command => $command, verbose => $verbose);
+            unless ($success) {
+                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+                &my_die("Unable to perform dvoverify: $error_code", $mergedvodb, $error_code);
+            }
+            $dtime_verify = 86400.0*(DateTime->now->mjd - $mjd_dvoverify_start);   # MJD of starting script
+            print "dvoverify time $dtime_verify\n";
+        }
+
+
+	#Merge
 
         my $this_is_the_first;
@@ -190,4 +220,8 @@
 
 	{
+
+	    $dtime_script = 86400.0*(DateTime->now->mjd - $mjd_start);
+
+
             my $command = "addtool -minidvodb_id $minidvodb_id";
             $command .= " -addminidvodbprocessed";
@@ -197,5 +231,7 @@
             $command .= " -dtime_resort $dtime_resort" if defined $dtime_resort;
             $command .= " -dtime_merge $dtime_merge" if defined $dtime_merge;
-            $command .= " -dbname $dbname" if defined $dbname;
+	    $command .= " -dtime_script $dtime_script" if defined $dtime_script;
+	    $command .= " -dtime_verify $dtime_verify" if defined $dtime_verify;
+	    $command .= " -dbname $dbname" if defined $dbname;
             #print $command;
 
@@ -236,4 +272,6 @@
         $command .= " -dtime_resort $dtime_resort" if defined $dtime_resort;
         $command .= " -dtime_merge $dtime_merge" if defined $dtime_merge;
+    $command .= " -dtime_script $dtime_script" if defined $dtime_script;
+    $command .= " -dtime_verify $dtime_verify" if defined $dtime_verify;
         $command .= " -dbname $dbname" if defined $dbname;
 
Index: branches/eam_branches/ipp-20110213/ippScripts/scripts/register_exp.pl
===================================================================
--- branches/eam_branches/ipp-20110213/ippScripts/scripts/register_exp.pl	(revision 30812)
+++ branches/eam_branches/ipp-20110213/ippScripts/scripts/register_exp.pl	(revision 31083)
@@ -189,9 +189,9 @@
 
     if ($exptype ne 'OBJECT') {
-	print "Aborting because exptype doesn't claim to be OBJECT: $exptype\n";
+	print "Skipping because exptype doesn't claim to be OBJECT: $exptype\n";
 	return(undef,undef,undef,"reg",undef,undef,undef);
     }
     if ($obsmode eq 'ENGINEERING') {
-	print "Aborting because we don't queue engineering data to chip\n";
+	print "Skipping because we don't queue engineering data to chip\n";
 	return(undef,undef,undef,"reg",undef,undef,undef);
     }
Index: branches/eam_branches/ipp-20110213/ippScripts/scripts/register_imfile.pl
===================================================================
--- branches/eam_branches/ipp-20110213/ippScripts/scripts/register_imfile.pl	(revision 30812)
+++ branches/eam_branches/ipp-20110213/ippScripts/scripts/register_imfile.pl	(revision 31083)
@@ -267,5 +267,6 @@
 
 if ((abs($burntoolStateCurrent) != $burntoolStateTarget)&&
-    (!is_daytime($dateobs,$sunrise,$sunset))) {
+    (!is_daytime($dateobs,$sunrise,$sunset))&&
+    (!is_ccim($tmp_exp_name,$exp_type))) {
     my $mdcParser  = PS::IPP::Metadata::Config->new;
 
@@ -389,5 +390,5 @@
     my $exp_name = shift;
     my $exp_type = shift;
- 
+    $exp_type =~ s/'//g;
     # needs to match regtool.c checks for "is_ccim".
     if ($exp_name =~ /c/) {
Index: branches/eam_branches/ipp-20110213/ippScripts/scripts/stack_skycell.pl
===================================================================
--- branches/eam_branches/ipp-20110213/ippScripts/scripts/stack_skycell.pl	(revision 30812)
+++ branches/eam_branches/ipp-20110213/ippScripts/scripts/stack_skycell.pl	(revision 31083)
@@ -65,4 +65,31 @@
     and defined $run_state;
 
+# lists of file rules which we expect to produce output output
+my @outputList = qw(
+PPSTACK.OUTPUT
+PPSTACK.OUTPUT.MASK
+PPSTACK.OUTPUT.VARIANCE
+PPSTACK.OUTPUT.EXP          
+PPSTACK.OUTPUT.EXPNUM       
+PPSTACK.OUTPUT.EXPWT
+PPSTACK.TARGET.PSF          
+PPSTACK.OUTPUT.JPEG1        
+PPSTACK.OUTPUT.JPEG2        
+PPSTACK.CONFIG              
+);
+# produced if we run photometry
+my @outputListPhotom = qw(
+PSPHOT.OUT.CMF.MEF
+);
+# extra outputs when convolving
+my @outputListUnconv = qw(
+PPSTACK.UNCONV
+PPSTACK.UNCONV.MASK
+PPSTACK.UNCONV.VARIANCE
+PPSTACK.UNCONV.EXP          
+PPSTACK.UNCONV.EXPNUM       
+PPSTACK.UNCONV.EXPWT
+);
+
 my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $stack_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
 $| = 1;
@@ -73,12 +100,16 @@
 my $logDest = "$outroot.log";
 
-my $do_stats;
-if ($run_state eq 'new') {
-    $do_stats = 1;
-} else {
+if ($run_state eq 'update') {
     $logDest .= ".update";
 }
 
 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $stack_id, $PS_EXIT_SYS_ERROR ) if $redirect;
+
+my $neb;
+my $scheme = file_scheme($outroot);
+if ($scheme and $scheme eq 'neb') {
+    $neb = $ipprc->nebulous();
+}
+
 
 my $temp_images_exist = 0;
@@ -173,5 +204,5 @@
 my $output_nocomp = metadataLookupBool($recipe, 'OUTPUT.NOCOMP'); # change filerules to produced uncompressed output images
 my $output_logflux = metadataLookupBool($recipe, 'OUTPUT.LOGFLUX'); # change filerules to produce logflux compressed output images.
-
+my $replicate_outputs = (defined($neb) and metadataLookupBool($recipe, 'OUTPUT.REPLICATE')); # replicate output images
 if ($output_nocomp and $output_logflux) {
     &my_die("Unable to not compress and logflux compress simultaneously. Check config.",$stack_id, $PS_EXIT_CONFIG_ERROR);
@@ -212,30 +243,38 @@
 print "I've checked everything: $stack_id\n";
 
-# Get the output filenames
-my $outputName = $ipprc->filename("PPSTACK.OUTPUT", $outroot);
-my $outputMask = $ipprc->filename("PPSTACK.OUTPUT.MASK", $outroot);
-my $outputWeight = $ipprc->filename("PPSTACK.OUTPUT.VARIANCE", $outroot);
-my $outputSources = $photometry ? $ipprc->filename("PSPHOT.OUT.CMF.MEF", $outroot) : undef; ## this must be consistent with the value in diff_skycell.pl:101
+# Prepare the output files
+my @outputFiles;
+prepare_outputs(\@outputFiles, \@outputList, $outroot);
+prepare_outputs(\@outputFiles, \@outputListPhotom, $outroot) if $photometry;
+prepare_outputs(\@outputFiles, \@outputListUnconv, $outroot) if $convolve;
+
+# we need the output image name for the database
+my $outputName = $outputFiles[0];
 
 ## use an explicit stack name for psphot output objects
-#my $bin1Name =  $ipprc->filename("PPSTACK.BIN1", $outroot);
-#my $bin2Name =  $ipprc->filename("PPSTACK.BIN2", $outroot);
-my $outputStats = $ipprc->filename("SKYCELL.STATS", $outroot);
-my $traceDest = $ipprc->filename("TRACE.EXP", $outroot);
-$traceDest .= ".update" if $run_state eq 'update';
-my $configuration = $ipprc->filename("PPSTACK.CONFIG", $outroot);
+my $do_stats = 1;   
+my $outputStats;
+my $traceDest;
+my $configuration = prepare_output("PPSTACK.CONFIG", $outroot, 1);
+if ($run_state eq 'new') {
+    $outputStats = prepare_output("SKYCELL.STATS", $outroot, 1);
+    $traceDest = prepare_output("TRACE.EXP", $outroot, 1);
+    push @outputFiles, $configuration;
+    push @outputFiles, $outputStats;
+} else {
+    # we need to do stats regardless because we need the quality flag
+    # $do_stats = 0;
+    $outputStats = prepare_output("SKYCELL.STATS.UPDATE", $outroot, 1) if $do_stats;
+    $traceDest = prepare_output("TRACE.EXP.UPDATE", $outroot, 1);
+}
+
 $temp_images_exist = 1;  # failures after this point should attempt to delete the temp images
 
-# for update we need to resolve the config filename here because the code that reads it
-# doesn't know how to resolve paths. (The information is stored in the configuration file)
-$configuration = $ipprc->file_resolve($configuration) if ($run_state eq 'update');
-
 my $cmdflags;
-
 
 # Perform stacking
 unless ($no_op) {
     my $command = "$ppStack -input $listName $outroot";
-    $command .= " -stats $outputStats" if $do_stats;;
+    $command .= " -stats $outputStats" if $do_stats;
     $command .= " -recipe PPSTACK $recipe_ppStack";
     $command .= " -recipe PPSUB $recipe_ppSub";
@@ -311,15 +350,5 @@
 
     if (!$quality) {
-        &my_die("Couldn't find expected output file: $outputName", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputName);
-        &my_die("Couldn't find expected output file: $outputMask", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);
-        &my_die("Couldn't find expected output file: $outputWeight", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight);
-        if ($photometry) {
-            &my_die("Couldn't find expected output file: $outputSources", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);
-        }
-        if ($run_state eq 'new') {
-            &my_die("Couldn't find expected output file: $configuration", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($configuration);
-        }
-#       &my_die("Couldn't find expected output file: $bin1Name",    $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin1Name);
-#       &my_die("Couldn't find expected output file: $bin2Name",    $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin2Name);
+        check_outputs(\@outputFiles, $replicate_outputs);
     }
 
@@ -357,5 +386,5 @@
 }
 
-print "I've updated teh database: $stack_id\n";
+print "I've updated the database: $stack_id\n";
 
 
@@ -423,4 +452,52 @@
     }
 }
+sub prepare_output
+{
+    my $filerule = shift;
+    my $outroot  = shift;
+    my $delete = shift;
+    $delete = 0 if !defined $delete;
+
+    my $error;
+    my $output = $ipprc->prepare_output($filerule, $outroot, undef, $delete, \$error)
+                    or &my_die("failed to prepare output file for: $filerule", $stack_id, $error);
+    return $output;
+}
+
+sub prepare_outputs
+{
+    my $fileList = shift;
+    my $ruleList = shift;
+    my $outroot = shift;
+    
+    foreach my $rule (@$ruleList) {
+        push @$fileList, prepare_output($rule, $outroot, 1);
+    }
+}
+
+sub check_output
+{
+    my $file = shift;
+    my $replicate = shift;
+
+    if (!defined $file) {
+        return;
+    }
+
+    &my_die("Couldn't find expected output file: $file",  $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file);
+
+    if ($replicate and $neb) {
+        $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n",  $stack_id, $PS_EXIT_SYS_ERROR);
+    }
+}
+
+sub check_outputs
+{
+    my $fileList = shift;
+    my $replicate = shift;
+    foreach my $file (@$fileList) {
+        check_output($file, $replicate);
+    }
+}
 
 print "I've reached the end of processing with a code of $?: $stack_id\n";
@@ -432,3 +509,4 @@
 }
 
+
 __END__
Index: branches/eam_branches/ipp-20110213/ippScripts/scripts/summit_copy.pl
===================================================================
--- branches/eam_branches/ipp-20110213/ippScripts/scripts/summit_copy.pl	(revision 30812)
+++ branches/eam_branches/ipp-20110213/ippScripts/scripts/summit_copy.pl	(revision 31083)
@@ -22,5 +22,5 @@
 
 # Parse the command-line arguments
-my ( $uri, $filename, $compress, $bytes, $md5, $nebulous, $exp_name, $inst, $telescope, $class, $class_id, 
+my ( $uri, $filename, $compress, $bytes, $md5, $nebulous, $summit_id, $exp_name, $inst, $telescope, $class, $class_id, 
      $dbname, $verbose, $no_update, $no_op, $timeout, $copies );
 GetOptions(
@@ -31,4 +31,5 @@
        'md5=s'          => \$md5,       # reported md5 checksum
        'nebulous'       => \$nebulous,  # use nebulous for the target file
+       'summit_id=s'    => \$summit_id, # summit_id for this exposure
        'exp_name=s'     => \$exp_name,  # Exposure name
        'inst=s'         => \$inst,      # Instrument
@@ -45,8 +46,9 @@
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
-pod2usage( -msg => "Required options: --uri --filename --exp_name --inst --telescope --class --class_id",
+pod2usage( -msg => "Required options: --uri --filename --summit_id --exp_name --inst --telescope --class --class_id",
        -exitval => 3)
     unless defined $uri
     and defined $filename
+    and defined $summit_id
     and defined $exp_name
     and defined $inst
@@ -110,4 +112,5 @@
 $command  = "$pztool -copydone";
 $command .= " -row_lock";
+$command .= " -summit_id $summit_id";
 $command .= " -exp_name $exp_name";
 $command .= " -inst $inst";
@@ -236,4 +239,5 @@
         my $command;
         $command  = "$pztool -copydone";
+	$command .= " -summit_id $summit_id";
         $command .= " -exp_name $exp_name";
         $command .= " -inst $inst";
@@ -246,4 +250,16 @@
 
         system ($command);
+
+	if ($exit_code == 110) {
+	    $command = "$pztool -updatepzexp";
+	    $command .= " -exp_name $exp_name";
+	    $command .= " -camera $inst";
+	    $command .= " -telescope $telescope";
+	    $command .= " -set_state drop";
+	    $command .= " -dbname $dbname" if defined $dbname;
+
+	    system ($command);
+	}
+
     }
 
Index: branches/eam_branches/ipp-20110213/ippScripts/scripts/warp_skycell.pl
===================================================================
--- branches/eam_branches/ipp-20110213/ippScripts/scripts/warp_skycell.pl	(revision 30812)
+++ branches/eam_branches/ipp-20110213/ippScripts/scripts/warp_skycell.pl	(revision 31083)
@@ -76,5 +76,5 @@
     $traceDest = prepare_output("TRACE.EXP", $outroot, $skycell_id, 1);
 } elsif ($run_state eq 'update')  {
-    $logDest = prepare_output("LOG.EXP.UPDATE", $outroot, $skycell_id, 0);
+    $logDest = prepare_output("LOG.EXP.UPDATE", $outroot, $skycell_id, 1);
     $traceDest = prepare_output("TRACE.EXP.UPDATE", $outroot, $skycell_id, 1);
 } else {
@@ -318,10 +318,4 @@
 
         if (!$quality) {
-        #    &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputImage);
-        #    &my_die("Couldn't find expected output file: $outputMask", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);
-        #    &my_die("Couldn't find expected output file: $outputWeight", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight);
-        #    &my_die("Couldn't find expected output file: $outputSources", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);
-        #    &my_die("Couldn't find expected output file: $outputPSF", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) if metadataLookupBool($recipe, 'PSF') and not $ipprc->file_exists($outputPSF);
-
             check_output($outputImage, 0);
             check_output($outputMask, 0);
@@ -331,5 +325,4 @@
             if ($dump_config)  {
                 check_output($configuration, 1);
-#                &my_die("Couldn't find expected output file: $configuration", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($configuration);
             }
         }
