Fix multi-goroutine concurrency issues