Added some comments, renamed variables