Fixed a possible problem in deletemessage