Refactors the random-word routines.