simplify/restructure parse_metadata