Fix error with optimizations