Implement sum using foldl.
Cleanup of check.