Misc accumulated fixes

Here's a couple of minor fixes and enhancements built up over the last little while. Interesting for master?