More modularization.

got make_gen down to about 60 lines.