Fix minor issues found by static analysis, and add some additional code comments
Fix minor issues found by static analysis, and add some additional code comments for the benefit of anybody who has to squint at this code in the future.
This isn't quite ready yet. I'm opening this a bit early so I have a URL to refer to.