Added threading and semaphore for rendering