--- a/tools/PTuncrop.c
+++ b/tools/PTuncrop.c
@@ -24,85 +24,30 @@
  * 
  */
 
-#define PT_UNCROP_USAGE "PTuncrop [options] <inputFile> <outputFile>\n\n"\
-                         "Options:\n"\
-                         "-f\t\tForce processing (do not stop at warnings)\n"\
-			 "\t-q\t\tQuiet run\n\t-h\t\tShow this message\n"\
-                         "\n"
-
-#define PT_UNCROP_VERSION "PTuncrop Version " VERSION ", by Daniel M German\n"
 
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 
-#include "tiffio.h"
-#include "panorama.h"
-#include "filter.h"
 #include "PTcommon.h"
-#include "pttiff.h"
 
-int main(int argc,char *argv[])
+#define DEFAULT_PREFIX    "uncropped"
+
+#define PT_UNCROP_USAGE "PTuncrop [options] <inputFile> <outputFile>\n\n"\
+    "Options:\n"                                                        \
+    "\t-p <prefix>\tPrefix for output files (defaults to " DEFAULT_PREFIX "%%4d)\n"	\
+    "-f\t\tForce processing: Overwrite output file if it exists\n"      \
+    "\t-x\t\tDelete source files (use with care)\n"\
+    "\t-q\t\tQuiet run\n"\
+    "\t-h\t\tShow this message\n"\
+    "\n"
+
+#define PT_UNCROP_VERSION "PTuncrop Version " VERSION ", by Daniel M German\n"
+
+
+int main(int argc, char *argv[])
 {
-  char opt;
-  int filesCount;
-  char *inputFile, *outputFile;
-  FILE *testFile;
-  int ptForceProcessing = 0;
-  pano_cropping_parms cropParms;
-
-  
-  printf(PT_UNCROP_VERSION);
-
-  while ((opt = getopt(argc, argv, "fhq")) != -1) {
-
-// o overwrite
-// h       -> help
-// q       -> quiet?
-    
-    switch(opt) {  // fhoqs        f: 102 h:104  111 113 115  o:f:hsq
-    case 'f':
-      ptForceProcessing = 1;
-      break;
-    case 'q':
-      ptQuietFlag = 1;
-      break;
-    case 'h':
-      printf(PT_UNCROP_USAGE);
-      exit(0);
-    default:
-      break;
-    }
-  }
-  filesCount = argc - optind;
-
-  if (filesCount != 2) {
-    printf(PT_UNCROP_USAGE);
-    exit(0);
-  }
-
-  inputFile = argv[optind];
-  outputFile = argv[optind+1];
-
-  if (!ptForceProcessing) {
-    if ((testFile = fopen(outputFile, "r"))!= NULL) {
-	fprintf(stderr, "Output file already exists. Use -f to overwrite\n");
-	fclose(testFile);
-	exit(1);
-    }
-  }
-  
-  // prepare cropping parms
-
-  bzero(&cropParms, sizeof(cropParms));
-  cropParms.forceProcessing = ptForceProcessing;
-
-  if (panoTiffUnCrop(inputFile, outputFile, &cropParms))
-    return 0;
-	
-  
-  return -1;
-  
+    return panoCroppingMain(argc, argv, PANO_CROPPING_UNCROP, PT_UNCROP_VERSION, PT_UNCROP_USAGE, DEFAULT_PREFIX);
 }