Clean up static analyzer errors

* Clean up static analyzer errors
* Remove commented out lines
* Rearrange debug code