Fixes optimizer bug introduced in commit 35db76dd51f35058b53f15956af3bfd2538d32dd