First revision of main.cpp, not completed yet.