Fix #9 and a little tidy-up