Added some comments, deleted unused/commented out code, renamed variables