Remove duplicate code (many files are essentially the same)