Refactored the generator class to be usable from other python programs as-is.