Moved type check into add_message.