Add the mode hook definition. Fix a few spelling errors.
Some tidying up of comments, no change of code.