Protect against division by zero (svn r590540)
various protections against divisions by 0 (svn r590838)