Fix infinite recursion in map and foldl