Improved handling of metadata, especially on Linux/OSX