[M] Continued to refactor the main.cpp and the associated classes.