Fix #521: "ZeroDivisionError: float division by zero"