streamlined metadata handling and a few bug fixes