Heavily refactoring MainActivity.java. Added Application class. Added Preferences class.