fixed a few coding errors as well as typos, started adding comments