base_term: implement serialization.