Fix PHPDoc
Move some code and fix a typo
Extract dispatcher.