Overhauled main.cpp