Return nil instead of dividing by zero. Fixes #892