Refactoring and addition of comments.