Fixed race conditions