Fixed documentation.
Added detailed comments.