Refactoring; maybe fixes the generator behavior to be less ugly.