Added some documentation and code comments