Potential fix for Issue #365. Could you test this @tanghus?