Minor optimizations and tweaks