Implement TaskManager class and refactor dispersy