Add some checkpoints and make less memory copies