Index: trunk/psphot/src/psphot.h
===================================================================
--- trunk/psphot/src/psphot.h	(revision 21108)
+++ trunk/psphot/src/psphot.h	(revision 21166)
@@ -12,13 +12,4 @@
 
 #define PSPHOT_RECIPE_PSF_FAKE_ALLOW "PSF.FAKE.ALLOW" // Name for recipe component permitting fake PSFs
-
-typedef struct {
-    pmReadout *readout;
-    psArray *sources;
-    pmPSF *psf;
-    psRegion *region;
-    psMaskType maskVal;
-    psMaskType markVal;
-} psphotGuessModelForRegionArgs;
 
 // top-level psphot functions
@@ -43,5 +34,4 @@
 pmDetections   *psphotFindDetections (pmDetections *detections, pmReadout *readout, psMetadata *recipe);
 
-psArray        *psphotSourceStats (pmReadout *readout, psMetadata *recipe, pmDetections *detections);
 bool            psphotRoughClass (pmReadout *readout, psArray *sources, psMetadata *recipe, const bool findPsfClump);
 bool            psphotBasicDeblend (psArray *sources, psMetadata *recipe);
@@ -50,16 +40,32 @@
 bool            psphotMomentsStats (pmReadout *readout, psMetadata *recipe, psArray *sources);
 bool            psphotFitSourcesLinear (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final);
-bool            psphotGuessModels (pmConfig *config, pmReadout *readout, psArray *sources, pmPSF *psf);
-bool            psphotGuessModelForRegion (psphotGuessModelForRegionArgs *args);
-bool            psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
 bool            psphotReplaceUnfitSources (psArray *sources, psMaskType maskVal);
 bool            psphotReplaceAllSources (psArray *sources, psMetadata *recipe);
 bool            psphotRemoveAllSources (psArray *sources, psMetadata *recipe);
-bool            psphotApResid (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
-bool            psphotMagnitudes (pmConfig *config, const pmFPAview *view, psArray *sources, psMetadata *recipe, pmPSF *psf);
+
+bool            psphotBlendFit (pmConfig *config, pmReadout *readout, psArray *sources, pmPSF *psf);
+bool            psphotBlendFit_Threaded (psThreadJob *job);
+
+psArray        *psphotSourceStats (pmConfig *config, pmReadout *readout, pmDetections *detections);
+bool            psphotSourceStats_Threaded (psThreadJob *job);
+
+bool            psphotGuessModels (pmConfig *config, pmReadout *readout, psArray *sources, pmPSF *psf);
+bool            psphotGuessModel_Threaded (psThreadJob *job);
+
+bool            psphotMagnitudes (pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources, pmPSF *psf);
+bool            psphotMagnitudes_Threaded (psThreadJob *job);
+
+bool            psphotApResid (pmConfig *config, pmReadout *readout, psArray *sources, pmPSF *psf);
+bool            psphotApResidMags_Threaded (psThreadJob *job);
+
 bool            psphotSkyReplace (pmConfig *config, const pmFPAview *view);
 bool            psphotExtendedSourceAnalysis (pmReadout *readout, psArray *sources, psMetadata *recipe);
 bool            psphotExtendedSourceFits (pmReadout *readout, psArray *sources, psMetadata *recipe);
+
+// thread-related:
 bool            psphotSetThreads ();
+bool            psphotChooseCellSizes (int *Cx, int *Cy, pmReadout *readout, int nThreads);
+bool            psphotCoordToCell (int *group, int *cell, float x, float y, int Cx, int Cy);
+psArray        *psphotAssignSources (int Cx, int Cy, psArray *sources);
 
 // used by psphotFindDetections
