Revised code and comments.