Obvious fix for 0-size checkpoint. Cast fixes
More cast fixes
And more cast fixes