Added more comments, corrected some spelling, cleaned up code, renamed a few variables