a bunch of code reorderings to the scaled kernel