Resolve the race condition.
Merge pull request #54 from continuuity/feature/fix-dead-lock

Resolve the race condition.