Make sure we have a valid session before trying to log the user out.
Allow access to the customised materials component name even if it is disabled by the lecturer (e.g. by direct URL access)
Only mark topics as read when we have a valid current user/course relation.
Do not prematurely terminate threading; this fixed counting every post as a fork (which was not true.)