A bunch of miscellaneous fixes

I think this should be configurable instead.