Added documentation and did some fixes