Some general optimizations.