Various

A large amount of little fixes. See the commit messages for more info