Merge pull request #943 from am11/master

Code: Cleanup
HTML: Fixed potential crashes while formatting
Markdown: Fixed a crashing bug