Added documentation and code comments