Now reads the metadata and extracts the list of valid sections in the document. Algorithm may not be efficient, or perfect.