Added some comments and fixed a typo