cleaned it up some more for semaphore functions!