More better error handling in regen.py