Fix race condition in usb scanning code