Refactor page number code; fix off-by-one error and page number on archived threads