Refactor MainActivity.