Refactor generator code into separate classes.
(Work ongoing)