Small fixes to metadata code