Miscellaneous fixes

Small things.  See the issues mentioned in the commits.