fix some typos and code cleanup