A few fixes

The commit messages/diffs should explain what I've done.