Added documentation and did some reorganization