Update main.cpp

Code is growing. Splitting into multiple files for easier readability.