Fixed divergence of length.
Reworked length in terms of foldLeft.