Fix task manager bugs