Improve fix for #866