Set metadata step and convergence cleanup

Move some of the cleanup code and the SetMetadataItem functionality from #727 to here, so #727 can be smaller.
Yeah. @hynek has expressed that some predicate-based checks are desirable, they just haven't happened yet :)