Added some comments and fixed some typos