Better fix for #977