Fix a number of build concurrency bugs