Message model fixing and refactoring