Fixed an exponential recursion that could happen with doCheckpoint due
to lack of memoization
Formatting fixes