Noise curve code cleanup that also should fix a divide-by-zero bug