Refactored to used vectors. Now, to memoize it.