Improve error checking during replay (with a few clean-ups).

This provides the tool I need for (finally) making efficient progress on #183.