Cleaning up excess lines and pages