Correct spelling, and minor logic issues.