New comments added, some code formatted and the documentation is updated