Some revisions to code and comments