Move $num_per_page up and remove the comment about needing to adjust for the initial post (all evidence says the original formula was wrong and we should not adjust)
Constrain the page number to $num_pages so that we never get a page number that is too large. Fixes #23.
Modified to use the new paths
Use the proper path
We never counted the original post, so the +1 was the cause of the phantom page. Fixes #24.