some small changes in function maildelivery