Lots of performance improvements.

- Messages are now stored symmetrically.
- Messages are only retrieved and indexed on request (rather than immediately).
- Controllers can now pool several queries of the same type.