Fix linting errors and move functions

I moved functions out of the onSetUseLocation function in order to clean
up our syntax.