Updated documentation
Added some detailed comments to code