totalPages should be *TOTAL* pages, not just the number of pages merged in this round!