Index: /trunk/Ohana/src/imregister/src/detsearch.c
===================================================================
--- /trunk/Ohana/src/imregister/src/detsearch.c	(revision 74)
+++ /trunk/Ohana/src/imregister/src/detsearch.c	(revision 75)
@@ -1,5 +1,5 @@
 # include "imregister.h"
 # include "detrend.h"
-static char *version = "detsearch $Revision: 3.0 $";
+static char *version = "detsearch $Revision: 3.1 $";
 
 int main (int argc, char **argv) {
@@ -13,4 +13,6 @@
   args (argc, argv);
 
+  if (output.Criteria) PrintCriteria ();
+	
   status = load_db ();
   if (!status) {
@@ -18,5 +20,5 @@
     exit (0);
   }
-  if (!output.Modify && !output.Delete) close_db ();
+  if (!output.Modify && !output.Delete && !output.Altpath) close_db ();
   
   match = MatchCriteria (&Nmatch);          /* match basic criteria */
@@ -24,6 +26,4 @@
   match = CloseCriteria (match, &Nmatch);   /* reduce matches based on closeness */
 
-  if (output.Criteria) PrintCriteria ();
-	
   if (output.Select) {
     match = UniqueSubset (match, &Nmatch);
@@ -35,4 +35,5 @@
   }
 
+  if (output.Altpath) SetAltpath (match, Nmatch);
   if (output.Modify) ModifySubset (match, Nmatch);
   if (output.Delete) DeleteSubset (match, Nmatch);
Index: /trunk/Ohana/src/imregister/src/imregister.c
===================================================================
--- /trunk/Ohana/src/imregister/src/imregister.c	(revision 74)
+++ /trunk/Ohana/src/imregister/src/imregister.c	(revision 75)
@@ -1,5 +1,5 @@
 # include "imregister.h"
 # include "imreg.h"
-static char *version = "imregister $Revision: 3.1 $";
+static char *version = "imregister $Revision: 3.2 $";
 
 int main (int argc, char **argv) {
@@ -15,5 +15,5 @@
   /* define new entries (pimage, Nnew) */
   switch (image[0].mode) {
-  case MODE_CUBE:
+  case M_CUBE:
     Nnew = image[0].ccd + 1;
     ALLOCATE (pimage, RegImage, Nnew);
@@ -23,9 +23,9 @@
       pimage[i] = image[0]; 
       pimage[i].ccd = i - 1;
-      pimage[i].mode = MODE_SLICE;
+      pimage[i].mode = M_SLICE;
       pimage[i].obstime += *dtime*pimage[i].ccd;
     }
     break;
-  case MODE_MEF:
+  case M_MEF:
     Nnew = image[0].ccd;
     ALLOCATE (pimage, RegImage, Nnew);
@@ -35,6 +35,6 @@
     }
     break;
-  case MODE_SPLIT:
-  case MODE_SINGLE:
+  case M_SPLIT:
+  case M_SINGLE:
     Nnew = 1;
     pimage = &image[0];
Index: /trunk/Ohana/src/imregister/src/imsort.c
===================================================================
--- /trunk/Ohana/src/imregister/src/imsort.c	(revision 74)
+++ /trunk/Ohana/src/imregister/src/imsort.c	(revision 75)
@@ -1,5 +1,5 @@
 # include "imregister.h"
 # include "imreg.h"
-static char *version = "imsort $Revision: 3.1 $";
+static char *version = "imsort $Revision: 3.2 $";
 
 int main (int argc, char **argv) {
@@ -15,5 +15,5 @@
   /* define new entries (pimage, Nnew) */
   switch (image[0].mode) {
-  case MODE_CUBE:
+  case M_CUBE:
     Nnew = image[0].ccd + 1;
     ALLOCATE (pimage, RegImage, Nnew);
@@ -23,9 +23,9 @@
       pimage[i] = image[0]; 
       pimage[i].ccd = i - 1;
-      pimage[i].mode = MODE_SLICE;
+      pimage[i].mode = M_SLICE;
       pimage[i].obstime += *dtime*pimage[i].ccd;
     }
     break;
-  case MODE_MEF:
+  case M_MEF:
     Nnew = image[0].ccd;
     ALLOCATE (pimage, RegImage, Nnew);
@@ -35,6 +35,6 @@
     }
     break;
-  case MODE_SPLIT:
-  case MODE_SINGLE:
+  case M_SPLIT:
+  case M_SINGLE:
     Nnew = 1;
     pimage = &image[0];
Index: /trunk/Ohana/src/imregister/src/imstatreg.c
===================================================================
--- /trunk/Ohana/src/imregister/src/imstatreg.c	(revision 74)
+++ /trunk/Ohana/src/imregister/src/imstatreg.c	(revision 75)
@@ -1,5 +1,5 @@
 # include "imregister.h"
 # include "imreg.h"
-static char *version = "imstatreg $Revision: 3.2 $";
+static char *version = "imstatreg $Revision: 3.3 $";
 
 int main (int argc, char **argv) {
@@ -7,6 +7,7 @@
   RegImage *image;
   float *dtime;
-  int i, *match, Nmatch, status, child;
+  int i, *match, Nmatch, status, child, Nentry;
   char *TempDB, *LogFile;
+  FILE *f;
 
   get_version (argc, argv, version);
@@ -15,6 +16,9 @@
   if (CLIENT) imregclient (argv[1], argv[2], argv[3]);
 
+  /* create db.log and db.bfr */
   ALLOCATE (TempDB, char, strlen (ImageDB) + 10);
   sprintf (TempDB, "%s.bfr", ImageDB);
+  ALLOCATE (LogFile, char, strlen (ImageDB) + 10);
+  sprintf (LogFile, "%s.log", ImageDB);
 
   SetSignals ();
@@ -33,27 +37,27 @@
 
   /* redirect stderr, stdout to logfile */
-  ALLOCATE (LogFile, char, strlen (ImageDB) + 10);
-  sprintf (LogFile, "%s.log", ImageDB);
-  tmpfd = freopen (LogFile, "w", stderr);
-  if (tmpfd == (FILE *) NULL) 
-    fprintf (LogFile, "can't open log file %s, writing to stderr\n", LogFile);
+  f = freopen (LogFile, "w", stderr);
+  if (f == (FILE *) NULL) 
+    fprintf (stderr, "can't open log file %s, writing to stderr\n", LogFile);
   else 
-    stderr = tmpfd;
-  tmpfd = freopen (LogFile, "w", stdout);
-  if (tmpfd == (FILE *) NULL) 
-    fprintf (LogFile, "can't open log file %s, writing to stderr\n", LogFile);
+    stderr = f;
+  f = freopen (LogFile, "w", stdout);
+  if (f == (FILE *) NULL) 
+    fprintf (stderr, "can't open log file %s, writing to stderr\n", LogFile);
   else 
-    stdout = tmpfd;
+    stdout = f;
 
-    /* start loop */
+  /* start loop */
   while (1) {
 
-    fflush (stderr);
-    fflush (stdout);
     set_db (TempDB);
     status = load_db ();
     if (!status) {
       fprintf (stderr, "temporary database is empty\n");
-      close_db (); sleep (60); continue;
+      close_db (); 
+      fflush (stderr);
+      fflush (stdout);
+      sleep (60); 
+      continue;
     }
     image = get_images (&Nentry);
@@ -79,7 +83,7 @@
     unlink (TempDB);
     clearlockfile2 (TempDB, -1, LCK_HARD, &status);
+    fflush (stderr);
+    fflush (stdout);
     sleep (60);
   }
 }
-
-
