Now handle mem context when saving messages and removed useless debugging.