Port fix for #780