A few improvements

Hi @willmorgan, here are a few improvements I've made.

Sorry they are all bunched up - I consider them fairly minor, and they are all backwards compatible.

Happy to split up into separate pull requests, if needed.
@willmorgan what about feedback on this? I'm half way through changing it.