Fixed some dumb errors and renamed a variable or two