Fixed release build
Refactored main.cpp for more readability.