Remove duplicate and unused code