Fix wrong parent id being sent in message replies
Fix #158: fix duplicate message due to query join