cleaning bad refs