Refactor random generation a little