Fix names of functions and variables. Also fix some typos (incorporate Peter's comments).