Several improvements in design, safety and performance

That for now.
Next saving libass errors from callback into state, store header copy in state, change events storing and add code comments.
Same as L145.