Correct errors.
Use algorithms, little speed up.