Add Application class.

Put application initialization code to Application class.
Simplify main() logic.