Initial implementation of metadata serde

Why are you recalculating count again?