Fix metadata saving issue