Fix divide-by-zero crash