Minor metadata handling cleanup
Minor metadata handling cleanup

This code would benefit from a more general library to make
metadata handling easier.

travitch/foreign-inference,travitch/foreign-inference