Pull out the generator into a separate library.