fixed display for landscape orientation for main activity, and some code refactoring