Added XBee detection error checking.