Fix race condition in creating entities.
Merge pull request #41 from CruGlobal/fix_race_condition

Fix race condition