Bug fixes to do with concurrentcy problems