Added documentation in code plus a lot of code changes.