Index: branches/tap_branches/ppStack/src/ppStackPSF.c
===================================================================
--- branches/tap_branches/ppStack/src/ppStackPSF.c	(revision 25900)
+++ branches/tap_branches/ppStack/src/ppStackPSF.c	(revision 27838)
@@ -14,4 +14,6 @@
                   const psArray *psfs, const psVector *inputMask)
 {
+    bool mdok = false;
+
 #ifndef TESTING
     // Get the recipe values
@@ -24,4 +26,11 @@
     int psfOrder = psMetadataLookupS32(NULL, recipe, "PSF.ORDER"); // Spatial order for PSF
 
+    psString maskValStr = psMetadataLookupStr(&mdok, recipe, "MASK.VAL"); // Name of bits to mask going in
+    if (!mdok || !maskValStr) {
+        psError(PPSTACK_ERR_CONFIG, false, "Unable to find MASK.VAL in recipe");
+        return false;
+    }
+    psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask
+
     for (int i = 0; i < psfs->n; i++) {
         if (inputMask->data.U8[i]) {
@@ -32,8 +41,7 @@
 
     // Solve for the target PSF
-    pmPSF *psf = pmPSFEnvelope(numCols, numRows, psfs, psfInstances, psfRadius, psfModel,
-                               psfOrder, psfOrder);
+    pmPSF *psf = pmPSFEnvelope(numCols, numRows, psfs, psfInstances, psfRadius, psfModel, psfOrder, psfOrder, maskVal);
     if (!psf) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to determine output PSF.");
+        psError(PPSTACK_ERR_PSF, false, "Unable to determine output PSF.");
         return NULL;
     }
@@ -42,5 +50,5 @@
     pmPSF *psf = pmPSFBuildSimple("PS_MODEL_PS1_V1", 4.0, 4.0, 0.0, 1.0);
     if (!psf) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to build dummy PSF.");
+        psError(PPSTACK_ERR_PSF, false, "Unable to build dummy PSF.");
         return NULL;
     }
