Fixed: bugs in device authentication