Fixed a divide-by-zero error in DoRegen()