Merge pull request #548 from pusewicz/fix-math-degenerate-guards