Added a way to wait for asynch calls to end (with semaphores)