Added documentation.
Added documentation; beautified code.