Added some comments and changed some variable names.