Index: trunk/psphot/src/Makefile.am
===================================================================
--- trunk/psphot/src/Makefile.am	(revision 21381)
+++ trunk/psphot/src/Makefile.am	(revision 21392)
@@ -19,6 +19,14 @@
 	psphotImageLoop.c	\
 	psphotMosaicChip.c	\
-	psphotSetMaskBits.c	\
 	psphotParseCamera.c
+
+psphotDetect_SOURCES =            \
+        psphotDetect.c            \
+	psphotDetectArguments.c	  \
+	psphotDetectParseCamera.c \
+	psphotDetectImageLoop.c	  \
+	psphotDetectReadout.c	  \
+	psphotMosaicChip.c	  \
+	psphotCleanup.c
 
 psphotTest_SOURCES = \
Index: trunk/psphot/src/psphot.h
===================================================================
--- trunk/psphot/src/psphot.h	(revision 21381)
+++ trunk/psphot/src/psphot.h	(revision 21392)
@@ -60,4 +60,7 @@
 bool            psphotMagnitudes (pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources, pmPSF *psf);
 bool            psphotMagnitudes_Threaded (psThreadJob *job);
+
+bool            psphotPSFWeights(pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources);
+bool            psphotPSFWeights_Threaded (psThreadJob *job);
 
 bool            psphotApResid (pmConfig *config, pmReadout *readout, psArray *sources, pmPSF *psf);
Index: trunk/psphot/src/psphotDetect.h
===================================================================
--- trunk/psphot/src/psphotDetect.h	(revision 21381)
+++ trunk/psphot/src/psphotDetect.h	(revision 21392)
@@ -12,10 +12,12 @@
 
 // Top level functions
-pmConfig       *psphotArguments (int argc, char **argv);
-bool            psphotParseCamera (pmConfig *config);
-bool            psphotImageLoop (pmConfig *config);
-bool            psphotMosaicChip(pmConfig *config, const pmFPAview *view, char *outFile, char *inFile);
-void            psphotCleanup (pmConfig *config);
-psExit          psphotGetExitStatus ();
+pmConfig   *psphotDetectArguments(int argc, char **argv);
+bool        psphotDetectParseCamera (pmConfig *config);
+bool        psphotDetectImageLoop (pmConfig *config);
+bool        psphotDetectReadout(pmConfig *config, const pmFPAview *view);
+
+bool        psphotMosaicChip(pmConfig *config, const pmFPAview *view, char *outFile, char *inFile);
+void        psphotCleanup (pmConfig *config);
+psExit      psphotGetExitStatus ();
 
 #endif
Index: trunk/psphot/src/psphotDetectReadout.c
===================================================================
--- trunk/psphot/src/psphotDetectReadout.c	(revision 21381)
+++ trunk/psphot/src/psphotDetectReadout.c	(revision 21392)
@@ -30,5 +30,4 @@
     psAssert (psf, "psf should be loaded");
 
-
     // grab the sources of interest from the storage location (pmFPAfile PSPHOT.INPUT.CMF)
     psArray *sources = psphotLoadPSFSources (config, view);
@@ -59,5 +58,5 @@
 
     // calculate source magnitudes
-    psphotPSFWeights(config, readout, view, sources, psf);
+    psphotPSFWeights(config, readout, view, sources);
 
     // create the exported-metadata and free local data
Index: trunk/psphot/src/psphotMagnitudes.c
===================================================================
--- trunk/psphot/src/psphotMagnitudes.c	(revision 21381)
+++ trunk/psphot/src/psphotMagnitudes.c	(revision 21392)
@@ -199,9 +199,7 @@
 }
 
-# if (0)
-bool psphotPSFWeights(pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources, pmPSF *psf) {
+bool psphotPSFWeights(pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources) {
 
     bool status = false;
-    int Nap = 0;
 
     psTimerStart ("psphot.mags");
@@ -229,8 +227,4 @@
     maskVal |= markVal;
 
-    pmSourcePhotometryMode photMode = PM_SOURCE_PHOT_APCORR | PM_SOURCE_PHOT_WEIGHT;
-    if (!IGNORE_GROWTH) photMode |= PM_SOURCE_PHOT_GROWTH;
-    if (INTERPOLATE_AP) photMode |= PM_SOURCE_PHOT_INTERP;
-
     // choose Cx, Cy (see psphotThreadTools.c for overview of the concepts)
     int Cx = 1, Cy = 1;
@@ -249,5 +243,4 @@
 
 	    psArrayAdd(job->args, 1, cells->data[j]); // sources
-	    psArrayAdd(job->args, 1, psf);
 	    PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_IMAGE_MASK);
 
@@ -289,6 +282,5 @@
 
     psArray *sources                = job->args->data[0];
-    pmPSF *psf                      = job->args->data[1];
-    psImageMaskType maskVal         = PS_SCALAR_VALUE(job->args->data[2],PS_TYPE_IMAGE_MASK_DATA);
+    psImageMaskType maskVal         = PS_SCALAR_VALUE(job->args->data[1],PS_TYPE_IMAGE_MASK_DATA);
 
     for (int i = 0; i < sources->n; i++) {
@@ -314,5 +306,2 @@
     return true;
 }
-
-# endif
-
Index: trunk/psphot/src/psphotSetThreads.c
===================================================================
--- trunk/psphot/src/psphotSetThreads.c	(revision 21381)
+++ trunk/psphot/src/psphotSetThreads.c	(revision 21392)
@@ -12,4 +12,9 @@
     task = psThreadTaskAlloc("PSPHOT_MAGNITUDES", 8);
     task->function = &psphotMagnitudes_Threaded;
+    psThreadTaskAdd(task);
+    psFree(task);
+
+    task = psThreadTaskAlloc("PSPHOT_PSF_WEIGHTS", 2);
+    task->function = &psphotPSFWeights_Threaded;
     psThreadTaskAdd(task);
     psFree(task);
