Index: branches/eam_branches/ipp-20130904/ippTools/share/pstamptool_pendingdependent.sql
===================================================================
--- branches/eam_branches/ipp-20130904/ippTools/share/pstamptool_pendingdependent.sql	(revision 36192)
+++ branches/eam_branches/ipp-20130904/ippTools/share/pstamptool_pendingdependent.sql	(revision 36193)
@@ -1,4 +1,5 @@
 SELECT DISTINCT
     pstampDependent.*,
+    pstampRequest.label,
     concat( pstampDependent.outdir, '/checkdep.', dep_id, '.log') as logfile,
     IFNULL(Label.priority, 10000) AS priority
Index: branches/eam_branches/ipp-20130904/ippTools/share/releasetool_listrelstack.sql
===================================================================
--- branches/eam_branches/ipp-20130904/ippTools/share/releasetool_listrelstack.sql	(revision 36192)
+++ branches/eam_branches/ipp-20130904/ippTools/share/releasetool_listrelstack.sql	(revision 36193)
@@ -10,4 +10,6 @@
     skycalResult.path_base AS skycal_path_base,
     skycalRun.data_group AS skycal_data_group,
+    staticskyResult.sky_id AS sky_id,
+    staticskyResult.path_base AS staticsky_path_base,
     'GPC1' AS camera
 FROM relStack
@@ -18,2 +20,3 @@
 LEFT JOIN skycalRun USING(skycal_id)
 LEFT JOIN skycalResult USING(skycal_id)
+LEFT JOIN staticskyResult USING(sky_id)
Index: branches/eam_branches/ipp-20130904/ippm/FilesMonitoring/scripts/update_table.py
===================================================================
--- branches/eam_branches/ipp-20130904/ippm/FilesMonitoring/scripts/update_table.py	(revision 36192)
+++ branches/eam_branches/ipp-20130904/ippm/FilesMonitoring/scripts/update_table.py	(revision 36193)
@@ -7,5 +7,12 @@
 import datetime
 import hashlib
-from ipp.lifetime_templates import Template
+try:
+    from lifetime_templates import Template
+except ImportError:
+    sys.path.append('%s/%s/share/filemon/' % (os.environ['PSCONFDIR'], os.environ['PSCONFIG']))
+    sys.stderr.write('ImportError')
+    for folder in sys.path:
+        sys.stderr.write('\t%s\n' % folder)
+    from lifetime_templates import Template
 
 def md5sum(filename):
Index: branches/eam_branches/ipp-20130904/ippm/FilesMonitoring/scripts/update_table_undefined.py
===================================================================
--- branches/eam_branches/ipp-20130904/ippm/FilesMonitoring/scripts/update_table_undefined.py	(revision 36192)
+++ branches/eam_branches/ipp-20130904/ippm/FilesMonitoring/scripts/update_table_undefined.py	(revision 36193)
@@ -8,11 +8,11 @@
 import hashlib
 try:
-    from ipp.lifetime_templates import Template
+    from lifetime_templates import Template
 except ImportError:
-    sys.path.append('%s/%s/share/python/' % os.environ['PSCONFDIR'], os.environ['PSCONFIG'])
+    sys.path.append('%s/%s/share/filemon/' % (os.environ['PSCONFDIR'], os.environ['PSCONFIG']))
     sys.stderr.write('ImportError')
     for folder in sys.path:
         sys.stderr.write('\t%s\n' % folder)
-    from ipp.lifetime_templates import Template
+    from lifetime_templates import Template
 
 def md5sum(filename):
@@ -197,7 +197,8 @@
                                            'DisksMonitoring' )
     else:
-        filesMonitoring = MySQLdb.connect( 'localhost',
-                                           'ipp', 'ipp',
-                                           'DisksMonitoring' )
+#        filesMonitoring = MySQLdb.connect( 'localhost',
+#                                           'ipp', 'ipp',
+#                                           'DisksMonitoring' )
+        filesMonitoring = MySQLdb.connect('localhost', 'root', '', 'DisksMonitoring')
     max_batch_size = 2500
     if userlimit > max_batch_size:
Index: branches/eam_branches/ipp-20130904/ppImage/src/ppImageAuxiliaryMask.c
===================================================================
--- branches/eam_branches/ipp-20130904/ppImage/src/ppImageAuxiliaryMask.c	(revision 36192)
+++ branches/eam_branches/ipp-20130904/ppImage/src/ppImageAuxiliaryMask.c	(revision 36193)
@@ -35,4 +35,8 @@
         return NULL;
     }
+    if (image->type.type != PS_TYPE_IMAGE_MASK) {
+        psWarning("auxiliary mask image %s has unexpected type %d\n", realName, image->type.type);
+        return false;
+    }
     psFree(realName);
 
@@ -72,27 +76,10 @@
     }
 
-    // Find a suitable detRun with type AUXMASK
-
-    psTime *time = psMetadataLookupPtr(NULL, input->fpa->concepts, "FPA.TIME");
-    if (time->sec == 0 && time->nsec == 0) {
-        psLogMsg ("psModules.camera", PS_LOG_WARN, "FPA.TIME has not been set.\n");
-    }
-
-    char *cameraName = psMetadataLookupStr(NULL, input->fpa->concepts, "FPA.CAMERA");
-    pmDetrendSelectOptions *detrendOptions = pmDetrendSelectOptionsAlloc(cameraName, *time, PM_DETREND_TYPE_AUXMASK);
-
-    pmDetrendSelectResults *results = pmDetrendSelect(detrendOptions, config);
-    psFree(detrendOptions);
-    if (!results) {
-        psError (psErrorCodeLast(), false, "no matching auxiliary mask found");
-        return false;
-    }
-
-    pmFPALevel fileLevel = pmFPALevelFromName(results->level);
-    if (fileLevel != PM_FPA_LEVEL_CHIP) {
-         psError (PM_ERR_CONFIG, false, "invalid file level %d for selected auxiliary mask", fileLevel);
-         return false;
-    }
-    
+    pmFPAfile *auxmask = psMetadataLookupPtr(&status, config->files, "PPIMAGE.AUXMASK");
+    if (!status) {
+        psError(PS_ERR_UNEXPECTED_NULL, true, "PPIMAGE.CHIP file is not defined");
+        return false;
+    }
+
     // Go find the readout
     // code to find the readouts was adapted from ppImageSubtractBackground
@@ -129,31 +116,38 @@
         return true;
     }
-    // not needed psImage *image = ro->image;
+
     psImage *mask = ro->mask;
 
-    // now read the auxiliary mask file
-    psString class_id = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME");
-
-    char *auxMaskFileName = pmDetrendFile(results->detID, class_id, config);
-    if (!auxMaskFileName) {
-         psError (PM_ERR_CONFIG, false, "unable to find auxiliary mask file name for %s %s", results->detID, class_id);
-         return false;
-    }
-    psLogMsg ("ppImage", PS_LOG_INFO, "Auxiliary mask file: %s", auxMaskFileName);
-
-    psFree(results);
-    // record that we read this file in the config dump file.
-    // Note: this value isn't used during updates though.
-    pmConfigRunFilenameAddRead(config, "PPIMAGE.AUXMASK", auxMaskFileName);
-    recordFileInHeader(chip, "DETREND.AUXMASK", "auxiliary mask", auxMaskFileName);
-
-    psImage *auxMask = readAuxiliaryMask(config, auxMaskFileName);
-    psFree(auxMaskFileName);
-    if (!auxMask) {
-        psError(PS_ERR_UNKNOWN, false, "failed to read auxiliary mask file");
-        return false;
-    }
-
-    // if the cell has video and the recipe value
+    if (mask->type.type != PS_TYPE_IMAGE_MASK) {
+        psWarning("mask image has unexpected type %d\n", mask->type.type);
+        return false;
+    }
+
+    pmChip *auxMaskChip = pmFPAviewThisChip(view, auxmask->fpa);
+    if (!auxMaskChip) {
+        psWarning("failed to find pmChip for auxiliary mask");
+        return false;
+    }
+    pmCell *auxMaskCell = auxMaskChip->cells->data[0];
+    if (!auxMaskCell) {
+        psWarning("failed to find pmCell for auxiliary mask");
+        return false;
+    }
+    pmReadout *auxMaskReadout = auxMaskCell->readouts->data[0];
+    if (!auxMaskReadout) {
+        psWarning("failed to find pmReadout for auxiliary mask");
+        return false;
+    }
+    psImage *auxMaskImage = auxMaskReadout->mask;
+    if (!auxMaskImage) {
+        psWarning("failed to find psImage for auxiliary mask");
+        return false;
+    }
+    if (auxMaskImage->type.type != PS_TYPE_IMAGE_MASK) {
+        psWarning("auxiliary mask image has unexpected type %d\n", auxMaskImage->type.type);
+        return false;
+    }
+
+    // if the cell has video and the recipe value is set or in the video mask
     if (options->hasVideo && options->auxVideoMask && strcmp(options->auxVideoMask, "NULL")) {
         psImage *videoMask = readAuxiliaryMask(config, options->auxVideoMask);
@@ -166,7 +160,7 @@
         recordFileInHeader(chip, "DETREND.AUXVIDEOMASK", "auxiliary video mask", options->auxVideoMask);
 
-        // compute auxMask *= videoMask
-        if (!psBinaryOp(auxMask, auxMask, "*", videoMask)) {
-            psError(PS_ERR_UNKNOWN, false, "mulitplication of auxiliary mask and auxiliary video mask failed");
+        // compute auxMask |= videoMask
+        if (!psBinaryOp(auxMaskImage, auxMaskImage, "|", videoMask)) {
+            psError(PS_ERR_UNKNOWN, false, "combination of auxiliary mask and auxiliary video mask failed");
             return false;
         }
@@ -174,6 +168,6 @@
     }
 
-    if ((mask->numRows != auxMask->numRows) || (mask->numCols != auxMask->numCols) ||
-        (mask->row0 != auxMask->row0) || (mask->col0 != auxMask->col0)) {
+    if ((mask->numRows != auxMaskImage->numRows) || (mask->numCols != auxMaskImage->numCols) ||
+        (mask->row0 != auxMaskImage->row0) || (mask->col0 != auxMaskImage->col0)) {
         psError(PS_ERR_IO, false, "structure of auxiliary mask does not match this chip");
         return false;
@@ -187,11 +181,12 @@
     psAssert(staticMaskVal, "Need staticMaskVal!");
 
+    // XXX: now that we are using an auxilary mask that matches the format of ps masks, we could just
+    // do psBinaryOp(mask, mask, "|", auxMaskImage) but run an explicit loop so that we can measure
+    // and log the number of additional pixels masked
     int numCols = mask->numCols, numRows = mask->numRows; // Size of image
     unsigned long numMasked = 0;
     for (int y = 0; y < numRows; y++) {
         for (int x = 0; x < numCols; x++) {
-            // auxMask is floating point type image with pixel value 0 meaning mask it
-            // XXX: support other types and get the mask value from the header
-            if (auxMask->data.F32[y][x] == 0) {
+            if (auxMaskImage->data.U16[y][x] != 0) {
                 if ((mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & staticMaskVal) == 0) {
                     // pixel was not previously included in the static mask so mask it
@@ -200,6 +195,6 @@
                 }
                 // I don't need to do this.
+                // image->data.F32[y][x] = 0.0;
                 // The background subtraction code runs after us and will do it there
-                // image->data.F32[y][x] = 0.0;
 	    }
         }
@@ -213,6 +208,4 @@
     }
 
-    psFree(auxMask);
-
     return true;
 }
Index: branches/eam_branches/ipp-20130904/ppImage/src/ppImageParseCamera.c
===================================================================
--- branches/eam_branches/ipp-20130904/ppImage/src/ppImageParseCamera.c	(revision 36192)
+++ branches/eam_branches/ipp-20130904/ppImage/src/ppImageParseCamera.c	(revision 36193)
@@ -72,4 +72,12 @@
                                PM_FPA_FILE_MASK, PM_DETREND_TYPE_VIDEOMASK)) {
             psError(PS_ERR_IO, false, "Can't find a mask image source");
+            psFree(options);
+            return NULL;
+        }
+      }
+      if (options->doAuxMask) {
+	if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.AUXMASK", "MASK",
+                               PM_FPA_FILE_MASK, PM_DETREND_TYPE_AUXMASK)) {
+            psError(PS_ERR_IO, false, "Can't find a auxillary mask image source");
             psFree(options);
             return NULL;
