Refactor

cleanup now per source/entity
generalizes duplicate handling