Added a semaphore class for future threading