Buncha picks

This is a bunch of bugfix cherry-picks from the master branch.