Updated documentation and added comments