Index: /trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm
===================================================================
--- /trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm	(revision 27915)
+++ /trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm	(revision 27916)
@@ -208,8 +208,4 @@
     my $skycell_id;
 
-    if (isnull($component)) {
-        $component = undef;
-    }
-
     # note $magic_arg may be cleared below depending on $req_type
     my $magic_arg = $need_magic ? " -destreaked" : "";
@@ -221,5 +217,4 @@
     my $choose_components = 0;
     if ($stage eq "raw") {
-        $class_id = $component;
         $command = "$regtool -processedimfile -dbname $imagedb";
         # XXX: for now restrict lookups to type object 
@@ -227,16 +222,22 @@
         $command .= " -exp_type object";
         $id_opt = $use_imfile_id ? "-raw_imfile_id" : "-exp_id";
-        $component_args = " -class_id $class_id" if $component;
+
+        if ($component and $component ne 'all') {
+            $class_id = $component;
+            $component_args = " -class_id $class_id";
+        }
         $want_astrom = 1;
         $set_class_id = 1;
     } elsif ($stage eq "chip") {
-        $class_id = $component;
         # if the request is such that it will yield a single image per "run" or the
         # center is specified in pixel coordinates 
         # use chiptool -processsedimfile. Otherwise use chiptool -listrun and then
         # choose the chips containing the center pixel by calling selectComponets() below
-        if ($class_id or $use_imfile_id or !$skycenter) {
+        if ($component or $use_imfile_id or !$skycenter) {
             $command = "$chiptool -processedimfile -dbname $imagedb";
-            $component_args = " -class_id $class_id" if $class_id;
+            if ($component and $component ne 'all') {
+                $class_id = $component;
+                $component_args = " -class_id $class_id";
+            }
         } else {
             $command = "$chiptool -listrun -pstamp_order -dbname $imagedb";
@@ -256,8 +257,10 @@
         $set_class_id = 1;
     } elsif ($stage eq "warp") {
-        $skycell_id = $component;
-        if ($skycell_id or $use_imfile_id or !$skycenter) {
+        if ($component or $use_imfile_id or !$skycenter) {
             $command = "$warptool -warped -dbname $imagedb";
-            $component_args = " -skycell_id $skycell_id" if $skycell_id;
+            if ($component and $component ne 'all') {
+                $skycell_id = $component;
+                $component_args = " -skycell_id $skycell_id";
+            }
         } else {
             $command = "$warptool -listrun -pstamp_order -dbname $imagedb";
@@ -272,8 +275,10 @@
         $base_name    = "path_base"; # name of the field for the warptool output
     } elsif ($stage eq "diff") {
-        $skycell_id = $component;
-        if ($skycell_id or $use_imfile_id or !$skycenter) {
+        if ($component or $use_imfile_id or !$skycenter) {
             $command = "$difftool -diffskyfile -dbname $imagedb";
-            $component_args = " -skycell_id $skycell_id" if $skycell_id;
+            if ($component and $component ne 'all') {
+                $skycell_id = $component;
+                $component_args = " -skycell_id $skycell_id";
+            }
         } else {
             $command = "$difftool -listrun -pstamp_order -dbname $imagedb";
@@ -285,5 +290,5 @@
         $weight_name = "PPSUB.OUTPUT.VARIANCE";
         $cmf_name    = "PPSUB.OUTPUT.SOURCES";
-        $psf_name     = "PSPHOT.PSF.SKY.SAVE";
+        $psf_name    = "PSPHOT.PSF.SKY.SAVE";
         $base_name   = "path_base";
     } elsif ($stage eq "stack") {
@@ -883,6 +888,9 @@
         # If there are multiple cam runs for this exposure, take the last completed one with good quality
         # on the assumption that it has the best astrometry.
-        foreach $camRun (@$camruns) {
-            last if (($camRun->{state} eq 'full') and ($camRun->{quality} eq 0) and ($camRun->{fault} eq 0));
+        foreach my $cr (@$camruns) {
+            if (($cr->{state} eq 'full') and ($cr->{quality} eq 0) and ($cr->{fault} eq 0)) {
+                $camRun = $cr;
+                last;
+            }
         }
         # XXX: this looks like a bug at least if ASTROM.SOURCE eq PSASTRO.OUTPUT
