Major rewrite of the MessageServer. Cleanup and code folding for
preparing deeper client integration.