Re-implemented optimizations.