fix some typos and various bugs