Commenting code

Code documentation and formatting added.