MessageMapper<Id> mapper = factory.getMessageMapper(session);
// Ok we only search for a range so we can optimize the call
if (crits.size() == 1 && crits.get(0) instanceof UidCriterion) {
final List<Long> uids = new ArrayList<Long>();
UidCriterion uidCrit = (UidCriterion) crits.get(0);
NumericRange[] ranges = uidCrit.getOperator().getRange();
for (int i = 0; i < ranges.length; i++) {
NumericRange r = ranges[i];
Iterator<Message<Id>> messages = mapper.findInMailbox(mailbox, MessageRange.range(r.getLowValue(), r.getHighValue()), FetchType.Metadata, -1);
while(messages.hasNext()) {