Several small fixes.

Opening a PR for a bunch of small fixes so that they get reviewed.