Potential fix for #939

Please test and merge.