made some minor changes to semaphores