Fix typos and incorrect variable reference