Fixed typos and added a few comments in the code.