Try harder to avoid bad refs and missing files