Fix Semaphore bug