Doc update

Reorganized the doc page and made lots of little edits. Also edited some
code samples for clarity.
One more update for doc