Misc. patches to be cherry-picked if need be

These patches fix several little things unrelated to one another, feel free to cherry-pick what is of interest.