Fix typo
Improvements to code: make things clearer, more straight-forward etc. Also fixes an error with marking all read that would not have happened if the code had been clearer.