Major improvements to message handling