Added some comments and some minor changes