Minor code improvements

See the individual commits. Nothing major.