some code clean up in dispatcher