Misc fixes

These commits are pretty much totally unrelated. It might make more sense to evaluate each one individually.