  	kputc('\n', str);
  }
  
-@@ -1131,6 +1157,11 @@ mem_aln_t mem_reg2aln(const mem_opt_t *o
+@@ -1131,6 +1164,11 @@ mem_aln_t mem_reg2aln(const mem_opt_t *o
  	a.pos = pos - bns->anns[a.rid].offset;
  	a.score = ar->score; a.sub = ar->sub > ar->csub? ar->sub : ar->csub;
  	a.is_alt = ar->is_alt; a.alt_sc = ar->alt_sc;

 		for (i = 0; i < n_aa[0]; ++i)
 			mem_aln2sam(opt, bns, &str, &s[0], n_aa[0], aa[0], i, &h[1]); // write read1 hits
 		s[0].sam = strdup(str.s); str.l = 0;

Binary files bwa/QSufSort.o and bwa-mod/QSufSort.o differ
Binary files bwa/bamlite.o and bwa-mod/bamlite.o differ
Binary files bwa/bntseq.o and bwa-mod/bntseq.o differ
Binary files bwa/bwa and bwa-mod/bwa differ
Binary files bwa/bwa.o and bwa-mod/bwa.o differ
diff -rupN -x Xcode -x .git bwa/bwamem.c bwa-mod/bwamem.c
--- bwa/bwamem.c	2015-07-08 13:14:28.000000000 -0400
+++ bwa-mod/bwamem.c	2015-08-28 15:12:12.000000000 -0400
@@ -942,6 +942,39 @@ void mem_aln2sam(const mem_opt_t *opt, c
 		for (i = tmp; i < str->l; ++i) // replace TAB in the comment to SPACE
 			if (str->s[i] == '\t') str->s[i] = ' ';
 	}
+	if ((p->flag & 4) == 0) {
+		kputsn("\tZT:Z:", 6, str);
+		kputs((char*)(p->cigar + p->n_cigar), str);
+		kputc(',', str);
+		kputw(p->score, str); // same as AS:i
+		kputc(',', str);
+		if(p->sub >= 0) {
+			kputw(p->score - p->sub, str);
+		} else {
+			kputsn("NA", 2, str);
+		}
+		kputc(',', str);
+		kputw(p->pair_score, str);
+		kputc(',', str);
+		if(p->pair_sub >= 0) {
+			assert(p->pair_score >= p->pair_sub);
+			kputw(p->pair_score - p->pair_sub, str);
+		} else {
+			kputsn("NA", 2, str);
+		}
+		kputc(',', str);
+		kputw(p->sub_n, str);
+		kputc(',', str);
