Added documentation and made some changes