Better fix for #1777