Fix serialization of closures