This sometimes results in a crash and it's logically wrong as it was. (cherry picked from commit 3d3fcd7a)