fix several bugs with html rendering