Backport a bunch of stuff to 1.0.x