Code cleanup + fix for large page numbers