I would have done more "atomic" functions, like "appendThread" (and maybe rename the existing one), "removeThread", "updateThread". But I'd agree to keep this for another bug.

However, I'd appreciate if you could see how to take a thread id as argument here instead of a message, the interface would feel cleaner.