Improve fix for #1239