Lots of cleanup: fix linter errors, bit of code organizatino, remove debug output, make comments better format / capitalization / spelling / punctuation.