added cq4 optimizations to cq2 and cq3 (#744)