Fix sync
Merge pull request #1 from guywithnose/master

Fix sync
Make the math more resilient.