Fix various typos on variable names, plus a divide by 0 problem.