Dispatcher corrections, refactoring and tests

Corrects problems from previous attempt. Fixes based on help comments from
the community and conflict resolution

Signed-off-by: Daan Hoogland <daan@onecht.net>
rats