remove invalid references