Various improvements

See commits.