Performance improvements and minor optimizations.