Tidy up and fix #107.