Fixed possible divisions by zero.