spell-checked and added more comments, as requested by code reviewers