Updated some code and adding comments.