Remove invalid references in file