Fix for Mantis 1084 from Andrew Plotkin