More robust metadata reading