General perfomance optimizations.
Merge remote-tracking branch 'megaton/master'