#940: add comments and tidy a bit