Fixed bug in mailbox code