Hack for write_metadata