Fixed a bug with dividing by zero.