Combined patch from qmail.jms1.net