Better fix for #505