Fixing issues in Sonar report

* Removing unused variables
* Improving error logging
* Correcting order of access modifiers, wrapping 80+ character lines, etc.