Documentation.

Added documentation to public properties/methods and rearranged some
code. No feature changes.