Minor fixes and improvements

See the commits for each one.