Minor HEAD catchup + fixes

It'd probably also be a good idea to cherry-pick the last commit in this pull request into master.