Typo fixes and cleanup of code