Remove invalid references