Rearrange 'context_switch' function.