Divide-by-zero fix provided by Niklas Nordin.