Avoiding and mitigating failures