Small misc. fixes

Miscellaneous fixes that didn't really seem to fit in a single commit, but as a whole became big enough to not directly push to master.