Fix bug3400

As discussed on the mailing list, here's the fix for bug #3400.