tidy up and fix #1