Minor optimizations to Q5