A flexible state-saving library for message-passing systems