Added some basic error handling to message processing.