Code cleanup on the algorithm. Made two versions to run the tests, one for the average case and one for the worst case. Both give similar (or better) results than described in ICSM ERA.