Fix exception on Settings Fragment 

Closes #998, and does some formatting of the source code.