Move some branches outside looped code. Should improve the generated asm (and