Port to rand 0.9
Per discussion on #1774 (closed), it's now okay to port to rand 0.9. There was a bit of work here, but !2868 (merged) helped some.
This branch is split up into several intermediate commits, each of which fixes a separate issue. I hope that this will make it easier to review.