Added documentation and made some minor changes.