Various minor optimizations