Index: branches/simmosaic_branches/ppStack/src/ppStackPSF.c
===================================================================
--- branches/simmosaic_branches/ppStack/src/ppStackPSF.c	(revision 24860)
+++ branches/simmosaic_branches/ppStack/src/ppStackPSF.c	(revision 27839)
@@ -9,7 +9,12 @@
 #include "ppStack.h"
 
+//#define TESTING
+
 pmPSF *ppStackPSF(const pmConfig *config, int numCols, int numRows,
                   const psArray *psfs, const psVector *inputMask)
 {
+    bool mdok = false;
+
+#ifndef TESTING
     // Get the recipe values
     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe
@@ -21,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]) {
@@ -29,10 +41,17 @@
 
     // 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;
     }
+#else
+    // Dummy PSF
+    pmPSF *psf = pmPSFBuildSimple("PS_MODEL_PS1_V1", 4.0, 4.0, 0.0, 1.0);
+    if (!psf) {
+        psError(PPSTACK_ERR_PSF, false, "Unable to build dummy PSF.");
+        return NULL;
+    }
+#endif
 
     return psf;
