Clean up duplicates and dead code.