Metadata de/serialization

still needs updates check comments