code cleanup and typo fixes