Since flattenHashtables alters the reader state by rewriting the metadata hashes, should it return and/or cache a flattened copy so that the original is preserved in case there is a need for the reader and/or user to modify it?  Updating the metadata would then invalidate the cached copy.