Refactor private random seed code

cc @hadley