TODO taken out of main.cpp to a separate file.