Fixed unecessary waiting!

Added new semaphore stuff. More testing probably required to validate if
solution is correct.