simplify checkpointing code and fix an offset