Added reference cell example and modified checkpoint call to send out current generated messages before saving state (emptying __messages)