Split main.cpp, cleaned up