Refactored code to work with Android Studio.