Index: /trunk/psastro/src/psastroAnalysis.c
===================================================================
--- /trunk/psastro/src/psastroAnalysis.c	(revision 17785)
+++ /trunk/psastro/src/psastroAnalysis.c	(revision 17786)
@@ -12,11 +12,11 @@
     psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSASTRO_RECIPE);
     if (!recipe) {
-	psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe");
-	return false;
+        psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe");
+        return false;
     }
 
     if (!psastroUseModel (config, recipe)) {
-	psError (PSASTRO_ERR_UNKNOWN, false, "failed to set model astrometry\n");
-	return false;
+        psError (PSASTRO_ERR_UNKNOWN, false, "failed to set model astrometry\n");
+        return false;
     }
 
@@ -24,10 +24,10 @@
     // apply the initial guess
     if (!psastroAstromGuess (&nStars, config)) {
-	psError (PSASTRO_ERR_UNKNOWN, false, "failed to determine initial astrometry guess\n");
-	return false;
+        psError (PSASTRO_ERR_UNKNOWN, false, "failed to determine initial astrometry guess\n");
+        return false;
     }
     if (nStars == 0) {
-	psLogMsg ("psastro", 2, "skipping astrometry analysis : no stars\n");
-	return true;
+        psLogMsg ("psastro", 2, "skipping astrometry analysis : no stars\n");
+        return false;
     }
 
@@ -35,17 +35,17 @@
     psArray *refs = psastroLoadRefstars(config);
     if (!refs) {
-	psError (PSASTRO_ERR_UNKNOWN, false, "failed to load reference data\n");
-	return false;
+        psError (PSASTRO_ERR_UNKNOWN, false, "failed to load reference data\n");
+        return false;
     }
     if (refs->n == 0) {
         psError(PSASTRO_ERR_REFSTARS, true, "no reference stars found");
         psFree(refs);
-        return NULL;
+        return false;
     }
 
     if (!psastroChooseRefstars (config, refs)) {
-	psError (PSASTRO_ERR_UNKNOWN, false, "failed to select reference data for chips\n");
+        psError (PSASTRO_ERR_UNKNOWN, false, "failed to select reference data for chips\n");
         psFree(refs);
-	return false;
+        return false;
     }
 
@@ -53,28 +53,28 @@
     bool chipastro = psMetadataLookupBool (&status, config->arguments, "PSASTRO.CHIP.MODE");
     if (!status) {
-	chipastro = psMetadataLookupBool (&status, recipe, "PSASTRO.CHIP.MODE");
+        chipastro = psMetadataLookupBool (&status, recipe, "PSASTRO.CHIP.MODE");
     }
     bool mosastro  = psMetadataLookupBool (&status, config->arguments, "PSASTRO.MOSAIC.MODE");
     if (!status) {
-	mosastro  = psMetadataLookupBool (&status, recipe, "PSASTRO.MOSAIC.MODE");
+        mosastro  = psMetadataLookupBool (&status, recipe, "PSASTRO.MOSAIC.MODE");
     }
     if (!chipastro && !mosastro) {
-	psLogMsg ("psastro", 3, "no astrometry mode selected, assuming chip astrometry\n");
-	chipastro = true;
+        psLogMsg ("psastro", 3, "no astrometry mode selected, assuming chip astrometry\n");
+        chipastro = true;
     }
 
     if (chipastro) {
-	if (!psastroChipAstrom (config)) {
-	    psError (PSASTRO_ERR_UNKNOWN, false, "failed to perform single chip astrometry\n");
-	    psFree(refs);
-	    return false;
-	}
-    } 
+        if (!psastroChipAstrom (config)) {
+            psError (PSASTRO_ERR_UNKNOWN, false, "failed to perform single chip astrometry\n");
+            psFree(refs);
+            return false;
+        }
+    }
     if (mosastro) {
-	if (!psastroMosaicAstrom (config)) {
-	    psError (PSASTRO_ERR_UNKNOWN, false, "failed to perform mosaic camera astrometry\n");
-	    psFree(refs);
-	    return false;
-	}
+        if (!psastroMosaicAstrom (config)) {
+            psError (PSASTRO_ERR_UNKNOWN, false, "failed to perform mosaic camera astrometry\n");
+            psFree(refs);
+            return false;
+        }
     }
 
Index: /trunk/psastro/src/psastroMosaicChipAstrom.c
===================================================================
--- /trunk/psastro/src/psastroMosaicChipAstrom.c	(revision 17785)
+++ /trunk/psastro/src/psastroMosaicChipAstrom.c	(revision 17786)
@@ -13,31 +13,33 @@
         psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
         if (!chip->process || !chip->file_exists) { continue; }
-	if (!chip->toFPA) { continue; }
-	
-	while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) {
+        if (!chip->toFPA) { continue; }
+
+        while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) {
             psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
             if (!cell->process || !cell->file_exists) { continue; }
 
-	    // process each of the readouts
-	    // XXX there can only be one readout per chip, right?
-	    while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) {
-		if (! readout->data_exists) { continue; }
+            // process each of the readouts
+            // XXX there can only be one readout per chip, right?
+            while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) {
+                if (! readout->data_exists) { continue; }
 
-		// save WCS and analysis metadata in update header
-		psMetadata *updates = psMetadataAlloc();
+                // save WCS and analysis metadata in update header
+                psMetadata *updates = psMetadataAlloc();
 
-		if (!psastroMosaicOneChip (chip, readout, recipe, updates, iteration)) {
-		    readout->data_exists = false;
-		    psLogMsg ("psastro", 3, "failed to find a solution for %d,%d,%d\n", view->chip, view->cell, view->readout);
-		    psFree (updates);
-		    continue;
-		}
+                if (!psastroMosaicOneChip (chip, readout, recipe, updates, iteration)) {
+                    readout->data_exists = false;
+                    psError(PS_ERR_UNKNOWN, false, "failed to find a solution for %d,%d,%d\n",
+                            view->chip, view->cell, view->readout);
+                    psFree(updates);
+                    psFree(view);
+                    return false;
+                }
 
-		// create the header keywords to descripe the results
-		pmAstromWriteBilevelChip (updates, chip, NONLIN_TOL);
-		psMetadataAddMetadata (readout->analysis, PS_LIST_TAIL, "PSASTRO.HEADER",  PS_META_REPLACE, "psastro header stats", updates);
-		psFree (updates);
-	    }
-	}
+                // create the header keywords to descripe the results
+                pmAstromWriteBilevelChip (updates, chip, NONLIN_TOL);
+                psMetadataAddMetadata (readout->analysis, PS_LIST_TAIL, "PSASTRO.HEADER",  PS_META_REPLACE, "psastro header stats", updates);
+                psFree (updates);
+            }
+        }
     }
     psFree (view);
