Minor optimizations and changes