renamed calc_pages to numpages.
refactored into modules.
refactored into modules.