Just added some comments and fixed variable names.