Start refactor of Generation

The Generation part of the script is not generating, so I am moving all
generation to functions and calling them where the current generation
is.