Add proper garbage cleanup when things fail.