Index: /trunk/stac/src/Makefile
===================================================================
--- /trunk/stac/src/Makefile	(revision 3666)
+++ /trunk/stac/src/Makefile	(revision 3667)
@@ -1,5 +1,5 @@
 SHELL = /bin/sh
 CC = gcc
-CFLAGS += -g -std=c99 -I/home/mithrandir/price/psLib/include -D_GNU_SOURCE # -DCRFLUX -DTESTING
+CFLAGS += -g -std=c99 -I/home/mithrandir/price/psLib/include -D_GNU_SOURCE # -DTESTING -DCRFLUX
 PSLIB += -L/home/mithrandir/price/psLib/lib/ -lpslib -lgsl -lgslcblas -lfftw3f -lsla -lcfitsio -lm -lxml2 -lmysqlclient
 LDFLAGS += $(PSLIB)
@@ -12,5 +12,5 @@
 	stacCombine.o stacInvertMaps.o stacSize.o
 
-SHIFTSIZE = shiftSize.o shiftSizeHelp.o stacWrite.o stacConfig.o stacRead.o stacCheckMemory.o stacSize.o
+SHIFTSIZE = shiftSize.o stacWrite.o stacConfig.o stacRead.o stacCheckMemory.o stacSize.o
 
 .PHONY: tags clean empty test profile optimise
Index: /trunk/stac/src/shiftSize.c
===================================================================
--- /trunk/stac/src/shiftSize.c	(revision 3666)
+++ /trunk/stac/src/shiftSize.c	(revision 3667)
@@ -14,4 +14,17 @@
 #include "stac.h"
 
+void help(const char *name)
+{
+    fprintf (stderr, "shiftSize: Calculate size for output combined image\n"
+	     "Usage: %s [-h] [-v] IN1 IN2...\n"
+	     "where\n"
+	     "\t-h           Help (this info)\n"
+	     "\t-v           Increase verbosity level\n"
+	     "\tIN1, IN2...  Input images, which have associated .map files.\n",
+	     name
+	);
+}
+
+
 int main(int argc, char *argv[])
 {
@@ -20,5 +33,4 @@
 #ifdef TESTING
     psTraceSetLevel("stac.checkMemory",10);
-    psTraceSetLevel("stac.config",10);
     psTraceSetLevel("stac.read",10);
     psTraceSetLevel("stac.size",10);
@@ -28,11 +40,9 @@
     psLogSetLevel(9);
 
+
+    int verbose = 0;			// Verbosity level
+
     // Parse command line
-    stacConfig *config = stacConfigAlloc(); // Configuration values
     const char *programName = argv[0];	// Program name
-
-    float saturated = 65535.0;		// Saturation level
-    float bad = 0.0;			// Bad level
-
     /* Variables for getopt */
     int opt;   /* Option, from getopt */
@@ -47,5 +57,5 @@
 	    exit(EXIT_SUCCESS);
 	  case 'v':
-            config->verbose++;
+            verbose++;
             break;
 	  default:
@@ -62,28 +72,28 @@
     }
 
-    // Get the input files
-    config->inputs = psArrayAlloc(argc);
+    psArray *inputs = psArrayAlloc(argc); // Input filenames
     for (int i = 0; i < argc; i++) {
-	config->inputs->data[i] = psAlloc(strlen(argv[i]));
-	strncpy(config->inputs->data[i], argv[i], strlen(argv[i]));
+	inputs->data[i] = psAlloc(strlen(argv[i]));
+	strncpy(inputs->data[i], argv[i], strlen(argv[i]));
     }
 
-
     // Read input files
-    psArray *inputs = stacReadImages(config);
+    psArray *images = stacReadImages(inputs);
 
     // Read maps
-    psArray *maps = stacReadMaps(config);
+    psArray *maps = stacReadMaps(inputs);
 
     // Get size
-    stacSize(config, inputs, maps);
+    int outnx, outny;			// Size of combined image
+    float xMapDiff, yMapDiff;		// Difference to apply to maps
+    stacSize(&outnx, &outny, &xMapDiff, &yMapDiff, images, maps);
 
-    printf("%d %d\n", config->outnx, config->outny);
+    printf("%d %d\n", outnx, outny);
 
     // Write out altered maps
-    stacWriteMaps(maps, config);
+    stacWriteMaps(inputs, maps);
 
-    psFree(config);
     psFree(inputs);
+    psFree(images);
     psFree(maps);
 
Index: unk/stac/src/shiftSizeHelp.c
===================================================================
--- /trunk/stac/src/shiftSizeHelp.c	(revision 3666)
+++ 	(revision )
@@ -1,14 +1,0 @@
-#include <stdio.h>
-
-void help(const char *name)
-{
-    fprintf (stderr, "shiftSize: Calculate size for output combined image\n"
-	     "Usage: %s [-h] [-v] IN1 IN2...\n"
-	     "where\n"
-	     "\t-h           Help (this info)\n"
-	     "\t-v           Increase verbosity level\n"
-	     "\tIN1, IN2...  Input images, which have associated .map files.\n",
-	     name
-	);
-}
-
Index: /trunk/stac/src/stac.c
===================================================================
--- /trunk/stac/src/stac.c	(revision 3666)
+++ /trunk/stac/src/stac.c	(revision 3667)
@@ -71,5 +71,5 @@
 	sprintf(errName,"%s.err",config->inputs->data[i]);
 	psFits *errorFile = psFitsAlloc(errName);
-	if (!psFitsWriteImage(errorFile, NULL, error, 0, NULL)) {
+	if (!psFitsWriteImage(errorFile, NULL, errors->data[i], 0, NULL)) {
 	    psErrorStackPrint(stderr, "Unable to write image: %s\n", errName);
 	}
@@ -91,15 +91,15 @@
 	char shiftName[MAXCHAR];	// Filename of shift image
 	char errName[MAXCHAR];		// Filename of error image
-	sprintf(shiftName,"%s.shift1",config->inputs->data[n],numTransforms);
-	sprintf(errName,"%s.shifterr1",config->inputs->data[n],numTransforms);
-	psTrace("stac.transform.test", 6,
-		"Output files have size: %dx%d\n",outImage->numCols,outImage->numRows);
+	sprintf(shiftName,"%s.shift1",config->inputs->data[i]);
+	sprintf(errName,"%s.shifterr1",config->inputs->data[i]);
 	psFits *shiftFile = psFitsAlloc(shiftName);
 	psFits *errFile = psFitsAlloc(errName);
-	if (!psFitsWriteImage(shiftFile, NULL, outImage, 0, NULL)) {
+	psImage *trans = transformed->data[i]; // Transformed image
+	psImage *transErr = transformedErrors->data[i];	// Transformed error image
+	if (!psFitsWriteImage(shiftFile, NULL, trans, 0, NULL)) {
 	    psErrorStackPrint(stderr, "Unable to write image: %s\n", shiftName);
 	}
 	psTrace("stac", 1, "Shifted image written to %s\n", shiftName);
-	if (!psFitsWriteImage(errFile, NULL, outError, 0, NULL)) {
+	if (!psFitsWriteImage(errFile, NULL, transErr, 0, NULL)) {
 	    psErrorStackPrint(stderr, "Unable to write image: %s\n", errName);
 	}
@@ -137,10 +137,10 @@
 #ifdef TESTING
     // Write rejection images out to check
-    for (int i = 0; i < nImages; i++) {
+    for (int i = 0; i < rejected->n; i++) {
 	char rejName[MAXCHAR];	// Filename of rejection image
-	sprintf(rejName,"%s.shiftrej",config->inputs->data[i]);
+	sprintf(rejName, "%s.shiftrej", config->inputs->data[i]);
 	
 	psFits *rejFile = psFitsAlloc(rejName);
-	if (!psFitsWriteImage(rejFile, NULL, (*rejected)->data[i], 0, NULL)) {
+	if (!psFitsWriteImage(rejFile, NULL, rejected->data[i], 0, NULL)) {
 	    psErrorStackPrint(stderr, "Unable to write image: %s\n", rejName);
 	}
@@ -151,5 +151,5 @@
     // Write out pre-combined image
     char preName[MAXCHAR];		// Filename of precombined image
-    sprintf(preName,"%s.pre",config->output);
+    sprintf(preName, "%s.pre", config->output);
     psFits *preFile = psFitsAlloc(preName);
     if (!psFitsWriteImage(preFile, NULL, combined, 0, NULL)) {
Index: /trunk/stac/src/stac.h
===================================================================
--- /trunk/stac/src/stac.h	(revision 3666)
+++ /trunk/stac/src/stac.h	(revision 3667)
@@ -192,9 +192,14 @@
 // stacWrite.c
 
-// Write maps out
+// Write map out
 bool stacWriteMap(const char *mapName,	// Filename to write to
 		  psPlaneTransform *map	// Map to write
     );
 
+// Write multiple maps
+bool stacWriteMaps(const psArray *names, // Filenames of the input images (will add ".map")
+		   const psArray *maps	// Maps to write
+    );
+
 /************************************************************************************************************/
 
Index: /trunk/stac/src/stacRejection.c
===================================================================
--- /trunk/stac/src/stacRejection.c	(revision 3666)
+++ /trunk/stac/src/stacRejection.c	(revision 3667)
@@ -83,5 +83,5 @@
 #ifdef TESTING
 	psImage *rejmap = psImageAlloc(nxInput, nyInput, PS_TYPE_F32); // The rejections in the source frame
-	psImage *grad = psImageAlloc(nxInput, nyInput, PS_TYPE_F32);	// The gradient image
+	psImage *gradient = psImageAlloc(nxInput, nyInput, PS_TYPE_F32);	// The gradient image
 #endif
 	psImage *reject = rejected->data[i]; // Pull out the mask in the output frame
@@ -147,5 +147,5 @@
 
 #ifdef TESTING
-			grad->data.F32[y][x] = stacGradient(inputs->data[i], x, y) / meanGrads;
+			gradient->data.F32[y][x] = stacGradient(inputs->data[i], x, y) / meanGrads;
 #endif
 
@@ -153,4 +153,5 @@
 			    mask->data.U8[y][x] = 1;
 			    nBad++;
+
 #ifdef CRFLUX
 			    fprintf(crs, "%d %d --> %f %f %f\n", x, y,
@@ -158,4 +159,5 @@
 				    stacGradient(inputs->data[i], x, y));
 #endif
+
 			} else {
 			    mask->data.U8[y][x] = 0;
@@ -200,5 +202,5 @@
 	}
 	psTrace("stac", 1, "Rejection map written to %s\n", rejmapName);
-	if (!psFitsWriteImage(gradFile, NULL, grad, 0, NULL)) {
+	if (!psFitsWriteImage(gradFile, NULL, gradient, 0, NULL)) {
 	    psErrorStackPrint(stderr, "Unable to write image: %s\n", gradName);
 	}
@@ -208,5 +210,5 @@
 	psFree(gradFile);
 	psFree(rejmap);
-	psFree(grad);
+	psFree(gradient);
 #endif
 
