refactor ClearUnusedTDefs