Cortex code optimization