Re-enabled semaphore logic.