Port fix for #766