shouldn't we have a "unregisterMessage" or something, when a message or thread is deleted?

I think I would have changed thread.messages to a Map instead of a global messages Map, at least for now, but having a global Map can have its uses too in the future. So I'm not against it.

Also, I'm a little bit afraid of having the whole db in memory... I agree we don't unless the user visits all the threads, but he'll likely visit the biggest threads, and we never reclaim that memory when he quits. Ideally we should reclaim that memory in case of memory pressure but I don't know if there is a way to do this currently.