Adding some of the generation algorithm.