Port fix for #1001