added documentation and comments.