Misc small fixes

Small improvements to various parts of the code base that I've accumulated while working in a few unfinished feature branches.