fixed some concurrentcy problems