Ideas for improved algorithm.