Remove duplicate inputs and outputs