Added naive checkpointing. Still some race conditions:\