Race condition issues with sync