Avoid sync race condition.
Merge pull request #5 from Raynos/patch-3

Avoid sync race condition.