Finished first phase of refactoring. The MainActivity now works.