Fix folds, change to use foldl' where possible