Add with_metadata karg and use namedtuple