Miscellaneous fixes for issues

Fixes a bunch of stuff reported by @Arantor