Fixed device scan bugs. Moved the device scan into a thread.