Minor optimizations

Minor optimizations throughout