Merge pull request #55 from nubs/master

Make the math more resilient.