external ref cleanup