Added some comments and minor changes