Refactored code
Refactored checkpointing code