Minor optimizations
Merge pull request #773 from d10/optimize

Minor optimizations.