Rearrange some code in dispatcher.