Replaced mutex with a counter based semaphore