Fix and clean TaskManager a bit.
Merge pull request #333 from whirm/taskmanager_fixes

Fix and clean TaskManager a bit.