Fix issue of failed material deletion