Added explanatory comments

Comments which explain the various functions were added.