remove bad references