Updated code to implement features and added comments.