HTML: Fixed potential crashes while formatting