Added documentation.
Added documentation and refactoring.