a bunch of changes

A bunch of useful changes - I can split these into separate pull requests if requested.
whoops... sorry about the bug here - somehow the fixup commit that fixed this got missed from this branch.