Removing bad references