Completed first version of main.cc still with bugs.