Fix handling of metadata