Nicer API for serialization.