Add MainPage widget class and do small refactoring