Code cleanup of main.cpp