Fix and clean TaskManager a bit.