fixes #2, print more about errors, added comments, correct a typo for #6 with max_pages.