refactored and simplified the message system.