ps_term: implement serialization.