Refactor how blocks and configs are persisted and restored.

Hopefully this will be clearer and easier to use.
Some of the tests need additional work to maintain full coverage.
As a result, this commit may contain bugs.  But it is already too long...