Added some comments and renamed things