Added documentation to code.
Reordered method declarations and added documentation.