Add some division by zero checks
Merge branch 'master' into travis.linux