Added debug tracing to a good deal of the code.
The paired/unpaired device name is now logged.
Fixed some possible NPEs and other warnings.