Added algorithm, new classes and changed main class.