Hoisted some things out of the loop in ocl_pack
Hoisted more things out of loop