Reformatting, added additional comments, and converted tabs to spaces