Broke out the main code into separate pieces