Fix for Mantis 1214 from Andrew Plotkin