diff --git a/fslchfiletype b/fslchfiletype
index b2d1a5dc37c6917c5ded25f0a0227a54ea5303e6..fe812a3628305ccc287747fa8257165651500c35 100755
--- a/fslchfiletype
+++ b/fslchfiletype
@@ -10,11 +10,7 @@
 #   SHCOPYRIGHT
 
 if [ $# -lt 2 ] ; then
-  echo "Usage: $0 <filetype> <filename> [filename2]" ;
-  echo " "
-  echo "  Changes the file type of the image file, or copies to new file"
-  echo "  Valid values of filetype are ANALYZE, NIFTI, NIFTI_PAIR,"
-  echo "                                 ANALYZE_GZ, NIFTI_GZ, NIFTI_PAIR_GZ"
+  ${FSLDIR}/bin/fslchfiletype_exe
   exit 1 ;
 fi
 
@@ -35,12 +31,11 @@ $FSLDIR/bin/fslchfiletype_exe $1 $oldfile $newfile
 # for inplace stuff remove and copy old one
 # exact mechanism is to be careful not to remove old IF a new one isn't writable in this place (eg over quota)
 if [ $inplace = 1 ] ; then
-  if [ `$FSLDIR/bin/imtest $newfile` = 1 ] ; then 
+  if [ `$FSLDIR/bin/imtest $newfile` = 1 ] ; then
       $FSLDIR/bin/immv $newfile ${oldfile}TMP
-      if [ `$FSLDIR/bin/imtest ${oldfile}TMP` = 1 ] ; then 
-	  $FSLDIR/bin/imrm $oldfile 
+      if [ `$FSLDIR/bin/imtest ${oldfile}TMP` = 1 ] ; then
+	  $FSLDIR/bin/imrm $oldfile
 	  $FSLDIR/bin/immv ${oldfile}TMP $oldfile
       fi
   fi
 fi
-
diff --git a/fslchfiletype.cc b/fslchfiletype.cc
index f70b8365f6aa9f493d59315a9863015565bbc505..b64810a91ef57b7c00ce9caa695676314f56477d 100644
--- a/fslchfiletype.cc
+++ b/fslchfiletype.cc
@@ -1,7 +1,7 @@
-//     fslchfiletype.cc  Conversion program for different volume types
+//     fslchfiletype.cc  Conversion program for different image types
 //     Matthew Webster, FMRIB Image Analysis Group
-//     Copyright (C) 2008 University of Oxford  
-//     CCOPYRIGHT  
+//     Copyright (C) 2008-2019 University of Oxford
+//     CCOPYRIGHT
 
 #include "newimage/newimageall.h"
 #include "newimage/fmribmain.h"
@@ -9,57 +9,51 @@
 
 using namespace NEWIMAGE;
 
-int printUsage(const string& progname) 
+
+int printUsage(const string& progname)
 {
-  cout << "Usage: " << progname << " <filetype> <filename> [filename2]" << endl << endl;
-  cout << "  Changes the file type of the image file, or copies to new file" << endl;
-  cout << "  Valid values of filetype are ANALYZE, NIFTI, NIFTI_PAIR," << endl;
-  cout << "                               ANALYZE_GZ, NIFTI_GZ, NIFTI_PAIR_GZ" << endl;
+  const vector<pair<string,int> > formats=NEWIMAGE::fileFormats::allFormats();
+  cout << "Usage: fslchfiletype[_exe] <filetype> <filename> [filename2]" << endl << endl;
+  cout << "Changes the file type of the image file [ or copies to new file ]." << endl;
+  cout << "Valid values for filetype are:" << endl;
+  for ( std::vector<const pair<string,int> >::iterator it=formats.begin(); it != formats.end(); it++ )
+    cout << "\t" << it->first << endl;
   return 1;
 }
 
+
 template <class T>
 int fmrib_main(int argc, char *argv[])
 {
   volume<T> input;
-  read_volume(input,string(argv[0]));
-  save_volume_dtype(input,string(argv[1]),dtype(string(argv[0])));
+  read_volume(input,string(argv[2]));
+  int format(-1);
+  const vector<pair<string,int> > formats=NEWIMAGE::fileFormats::allFormats();
+  for ( std::vector<const pair<string,int> >::iterator it=formats.begin(); it != formats.end(); it++ )
+    if ( string(argv[1]) == it->first ) format = it->second;
+  if ( format == -1 )
+    return printUsage(string(argv[0]));
+  string outputFile( argc == 4 ? string(argv[3]) : string(argv[2]) );
+  save_volume_dtype(input,outputFile,dtype(string(argv[2])),format);
   return 0;
 }
 
+
 int main(int argc,char *argv[])
 {
   if (argc < 3 || argc > 4)
     return printUsage(string(argv[0]));
 
   string inputFile(argv[2]);
-  string outputFile(argv[2]);
-  if (argc==4) outputFile=string(argv[3]);
-
-  int outputType(-1);
-  if (string(argv[1])=="ANALYZE") outputType=FSL_TYPE_ANALYZE;
-  else if (string(argv[1])=="NIFTI") outputType=FSL_TYPE_NIFTI;
-  else if (string(argv[1])=="NIFTI_PAIR") outputType=FSL_TYPE_NIFTI_PAIR;
-  else if (string(argv[1])=="ANALYZE_GZ") outputType=FSL_TYPE_ANALYZE_GZ;
-  else if (string(argv[1])=="NIFTI_GZ") outputType=FSL_TYPE_NIFTI_GZ;
-  else if (string(argv[1])=="NIFTI_PAIR_GZ") outputType=FSL_TYPE_NIFTI_PAIR_GZ;
-  else return printUsage(string(argv[0]));
+  string outputFile( argc == 4 ? string(argv[3]) : string(argv[2]) );
 
-  //argv[1] has a valid outtype at this point
-  setenv("FSLOUTPUTTYPE",argv[1], true);
-
-  if (dtype(inputFile)==DT_COMPLEX) 
+  if (dtype(inputFile)==DT_COMPLEX)
   {
     volume4D<float> real, imaginary;
     read_complexvolume(real, imaginary, inputFile);
     save_complexvolume(real, imaginary, outputFile);
+    return 0;
   }
-  else  
-  {
-    argv[0]= const_cast <char*>(inputFile.c_str());
-    argv[1]= const_cast <char*>(outputFile.c_str());
-    call_fmrib_main(dtype(inputFile),argc,argv);
-  }
+  call_fmrib_main(dtype(inputFile),argc,argv);
   return 0;
 }
-
diff --git a/fslcpgeom.cc b/fslcpgeom.cc
index 6911ec22f3bb49bbb42b0546175211d7ce42e573..41595b03b4dfd2ffd3375322cf59e73c7836049d 100755
--- a/fslcpgeom.cc
+++ b/fslcpgeom.cc
@@ -28,7 +28,7 @@ int avwcpgeom_main(int argc, char *argv[])
     return EXIT_FAILURE;
   }
 
-  short copydim=1;
+  short copydim( argc > 3 ? 0 : 1);
   char *buffer = NULL;
   size_t nbytes(max(headerSrc.nElements(),headerDest.nElements())*headerDest.bitsPerVoxel/8);
 
@@ -37,9 +37,6 @@ int avwcpgeom_main(int argc, char *argv[])
     return EXIT_FAILURE;
   }
 
-  if (argc>3)
-    copydim=0;
-
   vector<NiftiExtension> extensions;
   reader.loadImage(fullDestinationName,buffer,extensions,false);
 
diff --git a/fslcreatehd.cc b/fslcreatehd.cc
index 1e9ca3e98e22ac93706504e6da945e95fac6c34d..ce97d36dd85c7279829b67e1e47152b2988dcf9a 100755
--- a/fslcreatehd.cc
+++ b/fslcreatehd.cc
@@ -61,7 +61,7 @@ int fslcreatehd_main(int argc, char *argv[])
       header.sX[0]=-header.pixdim[1];
       header.sY[1]=header.pixdim[2];
       header.sZ[2]=header.pixdim[3];
-      header.sX[3]-=header.pixdim[1]*atoi(argv[9]);
+      header.sX[3]=-header.pixdim[1]*atoi(argv[9]);
       header.sY[3]=-header.pixdim[2]*atoi(argv[10]);
       header.sZ[3]=-header.pixdim[3]*atoi(argv[11]);
       header.qformCode=2;
diff --git a/fslhd.cc b/fslhd.cc
index 1bf97ba90f750f251b57d45c56c87f91d09b00e6..773bac17bcf9e288f87b1aa24bee0c8058c83765 100755
--- a/fslhd.cc
+++ b/fslhd.cc
@@ -1,7 +1,7 @@
 //     fslhd.cc - show image header
 //     Steve Smith, Mark Jenkinson and Matthew Webster, FMRIB Image Analysis Group
-//     Copyright (C) 2000-2012 University of Oxford  
-//     CCOPYRIGHT  
+//     Copyright (C) 2000-2012 University of Oxford
+//     CCOPYRIGHT
 
 #include "newimage/newimageall.h"
 #include <iomanip>
@@ -49,20 +49,22 @@ void reportXMLHeader(const NiftiHeader& header)
   cout << "  slice_dim = '" << (int)header.sliceDim() << "'" << endl;
   cout << "  descrip = '" << header.description << "'" << endl;
   cout << "  aux_file = '" << header.auxillaryFile << "'" << endl;
-  cout << "  qform_code = '" << header.qformCode << "'" << endl;
-  cout << "  qfac = '" << header.leftHanded() << "'" << endl;
-  cout << "  quatern_b = '" << header.qB << "'" << endl;
-  cout << "  quatern_c = '" << header.qC << "'" << endl;
-  cout << "  quatern_d = '" << header.qD << "'" << endl;
-  cout << "  qoffset_x = '" << header.qX << "'" << endl;
-  cout << "  qoffset_y = '" << header.qY << "'" << endl;
-  cout << "  qoffset_z = '" << header.qZ << "'" << endl;
+  if ( !header.isAnalyze() ) {
+    cout << "  qform_code = '" << header.qformCode << "'" << endl;
+    cout << "  qfac = '" << header.leftHanded() << "'" << endl;
+    cout << "  quatern_b = '" << header.qB << "'" << endl;
+    cout << "  quatern_c = '" << header.qC << "'" << endl;
+    cout << "  quatern_d = '" << header.qD << "'" << endl;
+    cout << "  qoffset_x = '" << header.qX << "'" << endl;
+    cout << "  qoffset_y = '" << header.qY << "'" << endl;
+    cout << "  qoffset_z = '" << header.qZ << "'" << endl;
+  }
   cout << "  sform_code = '" << header.sformCode << "'" << endl;
-  cout << "  sto_xyz_matrix = '"; 
+  cout << "  sto_xyz_matrix = '";
   mat44 output(header.getSForm());
   for (int i=0;i<4;i++)
     for (int j=0;j<4;j++) {
-     cout << output.m[i][j]; 
+     cout << output.m[i][j];
      if ( j==3 && i==3 )
        cout << "'" << endl;
      else
@@ -75,7 +77,7 @@ void reportXMLHeader(const NiftiHeader& header)
   cout << "/>" << endl;
 }
 
-int print_usage(const string& progname) 
+int print_usage(const string& progname)
 {
   cout << endl;
   cout << "Usage: fslhd [-x] <input>" << endl;
@@ -85,20 +87,19 @@ int print_usage(const string& progname)
 
 int main(int argc,char *argv[])
 {
-  if (argc < 2) 
+  if (argc < 2)
     return print_usage(string(argv[0]));
+  bool reportXML(argc==3 && strcmp(argv[1],"-x")==0 );
   NiftiIO reader;
   try {
     string filename(return_validimagefilename(argv[argc-1]));
     NiftiHeader header(reader.loadHeader(filename));
-    if ( argc==3 && strcmp(argv[1],"-x")==0 )
+    if (reportXML)
       reportXMLHeader(header);
     else {
-      cout << "filename\t" << filename << endl;
+      cout << "filename\t" << filename << endl << endl;
       header.report();
     }
   }  catch ( exception& e ) { cerr << e.what() << endl; return 1;}
   return 0;
 }
-
-