Various fixes

See the commit messages for further information.