cleanup device data after save DB and fix bugs.