Revert "changed some loops to faster map/fold/filter versions"

This reverts commit e273e44319771aa7a90020eefbdf290486bfebc6.