Mixed bag of small optimizations.

do we need to keep this code?