Minor optimizations

Some minor optimizations.