Avoid unnecessary classes creation.
Fix main.cpp indentation. Issue #2192.
Simplify main() logic.

Add Application class.
Put application initialization code to Application class.
Place some code into separate functions.
Use forward declarations in main.cpp.
Merge pull request #2289 from glassez/fix_main

Improve program startup code.