Added functionality and comments.