Metadata: hold state for each metadata and synchronize properly to the database