This is quite a large function, does inlining actually make it faster?