Record credit failures

Another step of #2508. Fixes #1811. Built on top of #2579.