Added comments

Code is prettified and comments are added everywhere.