Spelling error
Small logging change (see code comments)
Apply moodle code checker

Changed tabs to spaces, added whitespaces between if/for/... and (,
changed variable names, and some other thins.

Use: git diff --ignore-space-at-eol -b -w [commit] ...
to ignore the space changes.
Thanks to: https://coderwall.com/p/crj69a