Import optimization technique from new core.

Reduce binary size by ~2k.