Fixed a possible division by zero bug.