added comments and fixed typos