A bunch of miscellaneous fixes

Could be disabled, nobody will be watching that.