Automatic remediation and merge of devices