Revert "Total rewrite of generator"

This reverts commit 27a1ea0ef7c89ac19fa69324d9998999239a5809.