More improvements to regen.py