Add indexs and uniqueness constraints to message cost table.
Add check for message_direction on fallback message cost path.