add some failsafes when reading metadata