Updates to metadata extraction code

Still in progress.