Imporved algorithm significantly.