Malformed HTML in long history

We are using v5.0.3 and seeing some oddness in ticket history display. Wondering if anyone else has seen similar behavior and/or has suggestions for remedy.

Short version…
Tickets with long history, at a certain point (I haven’t gone to the trouble of figuring out if the break is consistent across tickets) history transactions fall outside of the collapsable div element. Then, if the history continues long enough after that, transactions start to lose formatting. This seems to be because they are another level up in the HTML, and so lose a css class attribute defined in a div.

In case my description is opaqaue:

<div> <!--Element has css attribute-->
	<div> <!--collapse target-->
	   Transactions here operate as expected.
	Transactions here are correctly formatted but don't collapse.
Transaction here don't collapse, and are oddly formatted.

The root cause seems to be malformed AJAX coming from the server which is then inserted into the history target.

Another interesting twist. In mid-January we upgraded from v3.6.11. To date I have not found any tickets created prior to the updgrade that show this behavior.