Renamed some variables and functions.
Added some comments.