Deduplication and cleanup