New span library and exposed spans in more places

Biggest change is the addition of the span sub-library. Other changes involve making more functions expose span information in the metadata and relaxing a few needlessly tight preconditions.