Correct serialization of closure functions