Lots of small tweaks

Revision from previous pull request