Main, Functions, comments

Recoded whole main.cpp and created functions.cpp for better readability.
Also added ton of comments so everybody could understand the code.