fixes bugs in mapping and metadata reading