Misc cleanup and improvements

See the three (unrelated) commits.