When using the new -useAllPages option added in 1.8.7, the usePageNum doesn't account for the fact that the specificOverlayPage is indexed by zero and the output ends up with overlay pages shifted
e.g. The output page 1 has page 2 from the overlay.
We need to subtract 1 from the pageNumber when getting the overlay page number.
int usePageNum = (pageNumber - 1) % numberOfOverlayPages;