put persistence code into an anonymous namespace
various fixes to state persistence code. added tracing. moved metadata compression state to header.