Minor optimizations and comments