Read metadata and minor bugfixes