Refactor operation context to extract out metadata functions