Various cleanup and comment improvement, done as part of code review, see #1.