WIP: RNG cleanups

Implement the changes described in #1307.