Misc optimizations.