Improved metadata handling