Refactor `plotpages.py`

Fixes issue #55 as well.