Some minor bug fixes and concurrency fixes