Added generate and randomize functions which may or may not work.