Reorder if-tests for message event parsing
Refactor, additional notes cleanup, fix TOC highlighting