Fixed typos, refactored some variables