Refactor `plotpages.py`

Fixes issues #36 and #55.