A bunch of miscellaneous fixes