Index: trunk/ppImage/src/ppImageOptions.c
===================================================================
--- trunk/ppImage/src/ppImageOptions.c	(revision 7508)
+++ trunk/ppImage/src/ppImageOptions.c	(revision 7531)
@@ -18,12 +18,4 @@
     options->nonLinearSource = NULL;
 
-    return options;
-}
-
-ppImageOptions *ppImageOptionsParse(pmConfig *config)
-{
-    bool status;
-    ppImageOptions *options = ppImageOptionsAlloc ();
-
     // default flags for various activities
     options->doMask   	= false;	// Mask bad pixels
@@ -36,13 +28,14 @@
     options->doFlat   	= false;	// Flat-field normalisation
     options->doFringe 	= false;	// Fringe subtraction
-    options->doSource 	= false;	// Source identification and photometry
+    options->doPhotom 	= false;	// Source identification and photometry
     options->doAstrom 	= false;	// Astrometry
+
+    options->doBin1 	= false;	// create binned image (scale 1)
+    options->doBin2 	= false;	// create binned image (scale 2)
+    options->doBin1JPG 	= false;	// create jpg of binned image (scale 1)
+    options->doBin2JPG 	= false;	// create jpg of binned image (scale 2)
 
     // Overscan defaults
     options->overscan      = NULL;	// Overscan options
-    bool overscanSingle    = false;	// A single value for entire overscan?
-    pmFit overscanFit      = PM_FIT_NONE; // Fit type for overscan
-    int overscanOrder      = 0;		// Order for overscan fit
-    psStats *overscanStats = NULL;      // Statistics for overscan
 
     // Non-linearity default options
@@ -50,4 +43,12 @@
     options->nonLinearData   = NULL;	// The non-linearity data
     options->nonLinearSource = NULL;    // If the non-linearity data is a menu, this provides the key
+
+    return options;
+}
+
+ppImageOptions *ppImageOptionsParse(pmConfig *config)
+{
+    bool status;
+    ppImageOptions *options = ppImageOptionsAlloc ();
 
     // select the recipe for this analysis
@@ -105,7 +106,9 @@
 
         // Do the overscan as a single value?
-        overscanSingle = psMetadataLookupBool(NULL, recipe, "OVERSCAN.SINGLE");
+        bool overscanSingle = psMetadataLookupBool(NULL, recipe, "OVERSCAN.SINGLE");
 
         // How do we fit it?
+	pmFit overscanFit = PM_FIT_NONE; // Fit type for overscan
+	int overscanOrder = 0;		// Order for overscan fit
         psString fit = psMetadataLookupStr(NULL, recipe, "OVERSCAN.FIT");
         if (! strcasecmp(fit, "POLYNOMIAL")) {
@@ -118,8 +121,10 @@
             overscanFit = PM_FIT_SPLINE;
         } else if (strcasecmp(fit, "NONE")) {
-            psLogMsg(__func__, PS_LOG_WARN, "OVERSCAN.FIT (%s) in recipe %s is not one of NONE, "
-                     "POLYNOMIAL, or SPLINE: assuming NONE.\n", fit, RECIPE_NAME);
+            psLogMsg(__func__, PS_LOG_WARN, "OVERSCAN.FIT (%s) in recipe %s is not one of NONE, POLYNOMIAL, or SPLINE", fit, RECIPE_NAME);
+	    exit(EXIT_FAILURE);
         }
 
+	// What method do we use to measure the overscan statistics?
+	psStats *overscanStats = NULL;	// Statistics for overscan
         psString stat = psMetadataLookupStr(NULL, recipe, "OVERSCAN.STAT");
         if (! strcasecmp(stat, "MEAN")) {
@@ -128,7 +133,6 @@
             overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN);
         } else {
-            psErrorStackPrint(stderr, "OVERSCAN.STAT (%s) in recipe %s is not one of MEAN, MEDIAN: "
-                              "assuming MEAN\n", stat, RECIPE_NAME);
-            overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
+            psErrorStackPrint(stderr, "OVERSCAN.STAT (%s) in recipe %s is not one of MEAN or MEDIAN", stat, RECIPE_NAME);
+	    exit(EXIT_FAILURE);
         }
 
@@ -161,9 +165,24 @@
 
     options->doBin1 = psMetadataLookupBool(NULL, recipe, "BIN1.FITS");
+    options->doBin1JPG = psMetadataLookupBool(NULL, recipe, "BIN1.JPEG");
+    if (options->doBin1JPG && !options->doBin1) {
+	psLogMsg(__func__, PS_LOG_ERROR, "Invalid Phase2 Options: cannot make JPG of Bin1 image without Bin1 image");
+	exit(EXIT_FAILURE);
+    }
+
     options->doBin2 = psMetadataLookupBool(NULL, recipe, "BIN2.FITS");
+    options->doBin2JPG = psMetadataLookupBool(NULL, recipe, "BIN2.JPEG");
+    if (options->doBin2JPG && !options->doBin2) {
+	psLogMsg(__func__, PS_LOG_ERROR, "Invalid Phase2 Options: cannot make JPG of Bin2 image without Bin2 image");
+	exit(EXIT_FAILURE);
+    }
+    
+    options->doPhotom = psMetadataLookupBool(NULL, recipe, "PHOTOM");
+    options->doAstrom = psMetadataLookupBool(NULL, recipe, "ASTROM");
+    if (options->doAstrom && !options->doPhotom) {
+	psLogMsg(__func__, PS_LOG_ERROR, "Invalid Phase2 Options: cannot do ASTROMetry without PHOTOMetry");
+	exit(EXIT_FAILURE);
+    }
 
-    // options->doBin1JPEG = psMetadataLookupBool(NULL, recipe, "BIN1.JPEG");
-    // options->doBin2JPEG = psMetadataLookupBool(NULL, recipe, "BIN2.JPEG");
-    
     return options;
 }
