Fix metadata writer