Added code to register / deregister a device when the unit is plugged in.