Fix issues in add device and scan operation