Make object-oriented. Change from recursive algorithm to iterative.