This is mostly an indenting / formatting change, along with adding comments.  Please see the first commit for the (small) functional changes.