Add semaphores and minor concurrency module refactoring.