Collect and cache metadata, run hooks on changes.