Add class to execute the algorithm.
Correct some bugs