Core organization

Split 'main.cc' in multiple classes.