Separate code of generator and driver

Object oriented programming is all about splitting code into individual units that have few responsibilities (ideally only one). This way they are easier to develop/test/maintain.