revamped checkpointing; not yet tested