Index: /trunk/Ohana/src/imregister/detrend/args.detsearch.c
===================================================================
--- /trunk/Ohana/src/imregister/detrend/args.detsearch.c	(revision 2449)
+++ /trunk/Ohana/src/imregister/detrend/args.detsearch.c	(revision 2450)
@@ -266,5 +266,5 @@
   }
  
-  output.Altpath = FALSE;
+  output.Altpath = NONE;
   if (N = get_argument (argc, argv, "-altpath")) {
     if (output.Delete) {
@@ -273,5 +273,12 @@
     }
     remove_argument (N, &argc, argv);
-    output.Altpath = TRUE;
+    if (!strcasecmp (argv[N], "add")) output.Altpath = ADD;
+    if (!strcasecmp (argv[N], "delete")) output.Altpath = DELETE;
+    if (!strcasecmp (argv[N], "update")) output.Altpath = UPDATE;
+    if (!output.Altpath) { 
+      fprintf (stderr, "invalid -altpath option\n");
+      exit (1);
+    }
+    remove_argument (N, &argc, argv);
   }
 
Index: /trunk/Ohana/src/imregister/detrend/imdef.c
===================================================================
--- /trunk/Ohana/src/imregister/detrend/imdef.c	(revision 2449)
+++ /trunk/Ohana/src/imregister/detrend/imdef.c	(revision 2450)
@@ -44,11 +44,4 @@
   }
 
-  /* modes: a special case */
-  if (descriptor[0].type == T_MODES) {
-    descriptor[0].mode      = M_MODES;
-    descriptor[0].CCD       = Nccd;
-    descriptor[0].CCDSelect = TRUE;
-  }
-
   /* identify MODE (MEF / SPLIT)  */
   descriptor[0].mode = M_SPLIT;
@@ -63,4 +56,11 @@
       fprintf (stderr, "warning: NEXTEND != Nccd (%d, %d)\n", Nextend, Nccd);
     }      
+  }
+
+  /* modes: a special case */
+  if (descriptor[0].type == T_MODES) {
+    descriptor[0].mode      = M_MODES;
+    descriptor[0].CCD       = Nccd;
+    descriptor[0].CCDSelect = TRUE;
   }
 
Index: /trunk/Ohana/src/imregister/detrend/output.c
===================================================================
--- /trunk/Ohana/src/imregister/detrend/output.c	(revision 2449)
+++ /trunk/Ohana/src/imregister/detrend/output.c	(revision 2450)
@@ -219,5 +219,5 @@
     filtstr = filterhash[MIN (MAX (detdata[i].filter, 0), NFILTER - 1)];
 
-    if (detdata[i].mode == M_SPLIT) {
+    if ((detdata[i].mode == M_SPLIT) && (detdata[i].ccd >= -1) && (detdata[i].ccd < Nccd)) {
       ccdstr   = ccds[detdata[i].ccd];
     } else {
Index: /trunk/Ohana/src/imregister/detrend/unique.c
===================================================================
--- /trunk/Ohana/src/imregister/detrend/unique.c	(revision 2449)
+++ /trunk/Ohana/src/imregister/detrend/unique.c	(revision 2450)
@@ -96,5 +96,5 @@
 
   if (crit[0].tstart  > image[0].tstop) return (FALSE);
-  if (crit[0].tstop   < image[0].tstop) return (FALSE);
+  if (crit[0].tstop   < image[0].tstart) return (FALSE);
 
   /* we have overlapping time ranges.  set crit[0] to have the 
