Updated main.cpp to be capable of running more than once.