Fixes to caching of metadata and conversion to/from JSON