Functions for clean or serialize