Refactoring main activity.