First attemp to refactor. Not working now.
Changes in dispatch library
Changes in package structure