Create generators

and other miscellaneous refactorings