Refactored and commented additional code. Next will be the settings activity