diff --git a/avwcpgeom.c b/avwcpgeom.c
index 1da1ea908a80b1e3de20aec8dcf9166f5b0bcb53..3da141a786da9f5cc68e5c28d0564d403b433721 100644
--- a/avwcpgeom.c
+++ b/avwcpgeom.c
@@ -35,7 +35,7 @@ int main(argc,argv)
      char **argv;
 {
 /*   struct dsr hdr, hdr2; */
-  FSLIO *src = NULL, *dest = NULL;
+  FSLIO *src = NULL, *dest = NULL, *destcopy = NULL;
   short x, y, z, v, copydim=1, t, scode, qcode, dt=-1;
   float vx, vy, vz, tr;
   int filetype;
@@ -59,6 +59,8 @@ int main(argc,argv)
 
 /*   avw_read_hdr(argv[2],&hdr2,&doswap); */
   dest = FslOpen(argv[2], "r");
+  destcopy = (FSLIO *)calloc(sizeof(FSLIO),1);
+  FslCloneHeader(destcopy,dest);
 
   if ((src == NULL) || (dest == NULL)) {
     perror("Error opening files");
@@ -70,7 +72,7 @@ int main(argc,argv)
      what will be written.  Otherwise there is a segfault when it comes to write. */
   FslGetDim(src, &x, &y, &z, &v);
   nsrcbytes = x * y * z * v * (FslGetDataType(dest, &t) / 8);
-  FslGetDim(dest, &x, &y, &z, &v);
+  FslGetDim(dest, &x, &y, &z, &v);  /* Also store these values for later */
   ndestbytes = x * y * z * v * (FslGetDataType(dest, &t) / 8);
   if (nsrcbytes > ndestbytes) nbytes=nsrcbytes; else nbytes=ndestbytes;
   if( (buffer = calloc(nbytes,1)) == NULL ) {
@@ -88,7 +90,8 @@ int main(argc,argv)
   /* ...and now reopen destination for writing */
   dest = FslXOpen(desthdrname, "wb", filetype);
 
-  FslCloneHeader(dest,src);
+  /* Want the old dest properties - just the geom from the src */
+  FslCloneHeader(dest,destcopy); 
 
 /* }}} */
   /* {{{ copy geom */
@@ -115,7 +118,7 @@ int main(argc,argv)
   
   if (copydim) {
     FslGetDim(src, &x, &y, &z, &v);
-    FslSetDim(src, x, y, z, v);
+    FslSetDim(dest, x, y, z, v);
   }
 
 /* }}} */
@@ -124,7 +127,7 @@ int main(argc,argv)
 /* if ( doswap )  */
 /*      swap_hdr(&hdr2); */
 
-  /* Preserve the datatype */ 
+  /* Preserve the datatype - probably unneccesary now, but left for safety */ 
   FslSetDataType(dest,dt);
 
  FslWriteHeader(dest);
diff --git a/fsledithd b/fsledithd
index f0942d4144586fdc4117ecfeae557b8bfab7cceb..1b718282e1f64b5c673cfeaeb3e9fdce6846eea2 100755
--- a/fsledithd
+++ b/fsledithd
@@ -31,6 +31,44 @@ if [ $# -ge 2 ] ; then
 fi
 
 tmpbase=`${FSLDIR}/bin/tmpnam`;
-${FSLDIR}/bin/avwhd -x $1 > ${tmpbase} || exit
+tmpbase2=`${FSLDIR}/bin/tmpnam`;
+
+# put in helpful comments at the start
+echo "# AVWEDITHD" > ${tmpbase}
+echo "# This text file contains the header information for an Analyze or Nifti file" >> ${tmpbase}
+echo "# Simply edit this file then save it and the header will be regenerated" >> ${tmpbase}
+echo "#   (note: if this editor is vi and you don't know it, quit by typing, in order, ESC Z Z )" >> ${tmpbase}
+echo "# All lines starting with the hash (#) character, like this line, will be ignored" >> ${tmpbase}
+echo "# Ensure that all lines intended to set values take the form: name = 'value' " >> ${tmpbase}
+echo "# Note that if the file is Analyze then many settings will be ignored" >> ${tmpbase}
+echo "# Further note that the filetype cannot be changed by this program" >> ${tmpbase}
+echo "#   i.e. changing the nifti_type has no effect" >> ${tmpbase}
+echo " " >> ${tmpbase}
+
+# generate the xml-style header with avwhd
+${FSLDIR}/bin/avwhd -x $1 | grep -v '/>' | grep -v '_filename' | grep -v '[^t]_name' | grep -v 'nvox' | grep -v 'to_ijk' | grep -v 'form_.*orientation' > ${tmpbase2}
+# exit if the above didn't generate a decent file
+if [ `cat ${tmpbase} | wc -l` -le 1 ] ; then
+  exit 0;
+fi
+# tack onto initial comments
+cat ${tmpbase2} >> ${tmpbase}
+# add stuff before end
+echo "# Many fields require codes to be set (e.g. sform_code, qform_code, intent_code)" >> ${tmpbase}
+echo "# Valid values are:" >> ${tmpbase}
+echo "#   sform_code (or qform) :- 0=UNKNOWN, 1=SCANNER_ANAT, 2=ALIGNED_ANAT, 3=TALAIRACH, 4=MNI_152" >> ${tmpbase}
+echo "#   xyz_units :- 1=METER, 2=MM, 3=MICRON " >> ${tmpbase}
+echo "#   t_units :- 8=SEC, 16=MSEC, 24=USEC, 32=HZ, 40=PPM, 48=RADS" >> ${tmpbase}
+echo "#   intent_code :- 0=NONE, 2=CORRELATION, 3=TTEST, 4=FTEST, 5=ZSCORE, 6=CHISQ, ..." >> ${tmpbase}
+echo "#                  22=PVAL, 23=LOGPVAL, 24=LOG10PVAL, 1001=ESTIMATE, 1002=LABEL (incl masks)" >> ${tmpbase}
+echo "#                  Other codes can be found in the $FSLDIR/src/niftiio/nifti1.h file" >> ${tmpbase}
+echo " " >> ${tmpbase}
+# close the xml-style part
+echo "/>" >> ${tmpbase}
+
+# edit header, reprocess and pass onto avwcreatehd
 ${EDITOR} ${tmpbase}
-${FSLDIR}/bin/avwcreatehd ${tmpbase} $1
+cat ${tmpbase} | grep -v '^[ 	]*#' | grep -v '^[ 	]*$' > ${tmpbase2}
+${FSLDIR}/bin/avwcreatehd ${tmpbase2} $1
+
+/bin/rm ${tmpbase} ${tmpbase2}