Clean up generator code further