Cleanup of generation script, based on the review from Campbell Barton
Fix assert happening in the wrong macro