Modified messaging code after code review.