I have 2 questions.
Are you using maintenace schedule ?
Are you using snmpcollector probe ?
If not, then here is easier way to clean up.
1. Remove all devices (callback in discovery_server - remove_all_master_devices)
2. Let UIM running for a while, then UIM will re-collect current inventory.