Optimization

Merged in optimizations.