fixed some typos, logic errors