Revised fix for #347