some various typos and logic fixes