Fix some bugs with html escaping