Refactored MainActivity for readability.