Update main code for new metadata scheme