I think this function is large enough to make it non-inline.