Code cleanups and typo fixes