Fixed some concurrency issues