Changes to semaphore logic