  				kputw(p->cigar[i]>>4, str); kputc("MIDSH"[c], str);
  			}
  		} else kputc('*', str); // having a coordinate but unaligned (e.g. when copy_mate is true)
-@@ -942,6 +947,50 @@ void mem_aln2sam(const mem_opt_t *opt, c
+@@ -942,6 +949,54 @@ 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] = ' ';
  	}

 }
diff -rupN -x Xcode -x .git bwa/bwamem.h bwa-mod/bwamem.h
--- bwa/bwamem.h	2015-07-08 13:14:28.000000000 -0400
+++ bwa-mod/bwamem.h	2016-07-29 21:04:27.000000000 -0400
@@ -94,6 +94,10 @@ typedef struct { // This struct is only 
 	char *XA;        // alternative mappings
 
 	int score, sub, alt_sc;
+	float seedcov, pair_seedcov;
+	int sub_n, pair_score, pair_sub, pair_nsub;
+	float frac_rep, pair_frac_rep;
+	int seedlen0, n_comp;
 } mem_aln_t;

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	2016-07-30 14:52:44.000000000 -0400
@@ -512,6 +512,8 @@ static void mem_mark_primary_se_core(con
 			int e_min = a[j].qe < a[i].qe? a[j].qe : a[i].qe;
 			if (e_min > b_max) { // have overlap
 				int min_l = a[i].qe - a[i].qb < a[j].qe - a[j].qb? a[i].qe - a[i].qb : a[j].qe - a[j].qb;
+				a[j].osub = a[j].osub < a[i].score ? a[i].score : a[j].osub;
+				a[j].osub_n++;
 				if (e_min - b_max >= min_l * opt->mask_level) { // significant overlap
 					if (a[j].sub == 0) a[j].sub = a[i].score;
 					if (a[j].score - a[i].score <= tmp && (a[j].is_alt || !a[i].is_alt))
@@ -838,6 +840,7 @@ void mem_aln2sam(const mem_opt_t *opt, c
 	ks_resize(str, str->l + s->l_seq + l_name + (s->qual? s->l_seq : 0) + 20);
 	kputsn(s->name, l_name, str); kputc('\t', str); // QNAME
 	kputw((p->flag&0xffff) | (p->flag&0x10000? 0x100 : 0), str); kputc('\t', str); // FLAG
