Bunch of unrelated fixes