diff --git a/uk/ac/sanger/artemis/components/alignment/BamUtils.java b/uk/ac/sanger/artemis/components/alignment/BamUtils.java
index b03c5be53f1e2ac07135efc0da2f56fdba11e273..a870c46e29a0a57e48fedecf04e23e0f56fe66cb 100644
--- a/uk/ac/sanger/artemis/components/alignment/BamUtils.java
+++ b/uk/ac/sanger/artemis/components/alignment/BamUtils.java
@@ -26,6 +26,7 @@ package uk.ac.sanger.artemis.components.alignment;
 import java.awt.Container;
 import java.awt.Frame;
 import java.text.DecimalFormat;
+import java.util.Arrays;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Vector;
@@ -81,8 +82,8 @@ class BamUtils
     {     
       Feature f = features.elementAt(i);
       
-      int start  = f.getFirstBase();
-      int end    = f.getLastBase();
+      int start  = f.getRawFirstBase();
+      int end    = f.getRawLastBase();
       float fLen = getFeatureLength(f);
       List<Float> sampleCounts = new Vector<Float>();
         
@@ -94,8 +95,8 @@ class BamUtils
         {
           for(int k=0; k<f.getSegments().size(); k++)
           {
-            start = f.getSegments().elementAt(k).getStart().getPosition();
-            end   = f.getSegments().elementAt(k).getEnd().getPosition();
+            start = f.getSegments().elementAt(k).getRawRange().getStart();
+            end   = f.getSegments().elementAt(k).getRawRange().getEnd();
             cnt += getCount(start, end, bam, refName, samFileReaderHash, 
               seqNames, offsetLengths, concatSequences, seqLengths, 
               samRecordFlagPredicate, samRecordMapQPredicate, contained); 
@@ -126,7 +127,10 @@ class BamUtils
     }
     buff.append("\n");
     
-    for (String fId : featureReadCount.keySet() ) {
+    Object[] readKey = featureReadCount.keySet().toArray();
+    Arrays.sort(readKey);
+    
+    for (Object fId : readKey ) {
       buff.append(fId+"\t");
       List<Float> cnts = featureReadCount.get(fId);
       for(int i=0; i<cnts.size(); i++)
@@ -242,17 +246,13 @@ class BamUtils
       final Hashtable<String, Integer> offsetLengths,
       final boolean concatSequences, 
       final Hashtable<String, Integer> seqLengths,
-      final int sequenceLength)
+      final int sequenceLength,
+      final SAMRecordPredicate samRecordFlagPredicate, 
+      SAMRecordMapQPredicate samRecordMapQPredicate)
   {
     int MAX_BASE_CHUNK = 2000*60;
     int mapped[] = new int[bamList.size()];
     boolean contained = false;
-    SAMRecordFlagPredicate samRecordFlagPredicate = new SAMRecordFlagPredicate(
-        (SAMRecordFlagPredicate.READ_UNMAPPED_FLAG | SAMRecordFlagPredicate.DUPLICATE_READ_FLAG));
-    //SAMRecordFlagPredicate p2 = new SAMRecordFlagPredicate(SAMRecordFlagPredicate.PROPER_PAIR_FLAG);
-    //SAMRecordFlagConjunctionPredicate samRecordFlagPredicate = new SAMRecordFlagConjunctionPredicate(p1, p2, 1, true, false);
-
-    SAMRecordMapQPredicate samRecordMapQPredicate = new SAMRecordMapQPredicate(-1);
 
     for (int i = 0; i < sequenceLength; i += MAX_BASE_CHUNK)
     {
@@ -313,7 +313,7 @@ class BamUtils
     int cnt = 0;
     SAMFileReader inputSam = samFileReaderHash.get(bam);
     final CloseableIterator<SAMRecord> it = inputSam.query(refName, start, end, contained);
-    
+
     while ( it.hasNext() )
     {
       SAMRecord samRecord = it.next();
diff --git a/uk/ac/sanger/artemis/components/alignment/BamView.java b/uk/ac/sanger/artemis/components/alignment/BamView.java
index 29d94216940a1e731e785b66fc7649ce3cab1a71..a11fa81e6669f385a16279ee35938f277b094724 100644
--- a/uk/ac/sanger/artemis/components/alignment/BamView.java
+++ b/uk/ac/sanger/artemis/components/alignment/BamView.java
@@ -2061,7 +2061,7 @@ public class BamView extends JPanel
         int mappedReads[] =
           BamUtils.getTotalMappedReads((String)combo.getSelectedItem(),
               samFileReaderHash, bamList, seqNames, offsetLengths, concatSequences, 
-              offsetLengths, seqlen);
+              offsetLengths, seqlen, samRecordFlagPredicate, samRecordMapQPredicate);
 
         logger4j.debug("TOTAL MAPPED READS "+mappedReads);
         BamUtils.countReads(features, (String)combo.getSelectedItem(), samFileReaderHash, bamList,