Added semaphores. They still need to be deleted...