Fix bugs, add semaphores, improve logging to be cross-device