Restructured and refactored the message system